scout-extended icon indicating copy to clipboard operation
scout-extended copied to clipboard

Reimporting aggregators only

Open mokhosh opened this issue 4 years ago • 7 comments

  • Laravel version: latest
  • Algolia Scout Extended version: latest
  • Algolia Client Version: latest

Description

With scout:reimport you can specify which searchable model you want to reimport. But if you have an aggregator called News for example you cannot say scout:reimport News, you get:

Class "News" not found 

Steps To Reproduce

Make an aggregator Try to reimport aggregator only

mokhosh avatar Mar 24 '21 05:03 mokhosh

Hi @mokhosh ,

Did you try passing the full classname (including namespace) to the command? For example, if your News aggregator lives in the default App\Search namespace:

php artisan scout:reimport "App\Search\News"

This should find the aggregator and reimport it. Let me know if it works for you 🙂

DevinCodes avatar Mar 29 '21 07:03 DevinCodes

Thanks @DevinCodes for the response. It did work. I think it would be nice to have a config for aggregates folder that defaults to "app/Search" and we would look there too in addition to models folder when we're reimporting, so we don't need to explicitly indicate the namespace.

mokhosh avatar Mar 29 '21 10:03 mokhosh

I would love to hear what others think of such an option before we decide to implement it 🙂 Let's discuss!

DevinCodes avatar Mar 29 '21 10:03 DevinCodes

Hi all,

I'm running the reimport like this php artisan scout:reimport "App\Search\News" however, it only runs for the first class in the $models array.

What am I doing wrong?

srlbarron avatar Oct 29 '21 15:10 srlbarron

Hi @srlbarron ,

Do all classes in your $models array implement the Searchable trait? If so, what happens if you change the order of your classes; does it still only import the first, or does it only import a specific class?

Thank you in advance!

DevinCodes avatar Nov 01 '21 14:11 DevinCodes

Hi @DevinCodes, I got it solved and I honestly don't know what it was.

Possible causes:

  • I was using a free account to test my stuff and it got quota'ed
  • Running on laravel 6 with newer scout versions
  • Lots of legacy custom code on my end (not my fault thought ;) )

srlbarron avatar Nov 01 '21 14:11 srlbarron

Okay, great to hear it got solved! 😄

Happy coding @srlbarron

DevinCodes avatar Nov 01 '21 14:11 DevinCodes