Laravel Scout - Only index in Aggregator Index

I have two models Subscription and Customer. They both have the Searchable trait in them along with custom toSearchableArray() functions. I have them both being aggregated into a single omni_search index.

I would prefer that they only go into the omni_search index and not into their own individual indexes when I run $model->searchable(). How would I go about preventing Scout from creating the model indexses and only let them update the omni_search index.

Thank you for the help!

Hi @WhoButSB, you can choose the index name to use for a model by setting a Custom Index name using the searchableAs() function documented here:https://www.algolia.com/doc/framework-integration/laravel/indexing/configure-index/?language=php#custom-index-name

Please bear in mind that if both models are being put in the same index as part of a federated search then they will be ranked together. This means that you will want to ensure that the attributes you use for their ranking are comparable so that they rank together properly.

For example if you are combining books and movies in the same index then only the movies might have a “run time” attribute and you would need to be careful when using this attribute in your ranking. You can learn more about federated search here: https://blog.algolia.com/what-is-federated-search

@matthew.bond - Unless I’m misunderstanding, I don’t think your answer, answers the original question. I have the same issue…

I’m using Laravel with Scout Extended and aggregating two models into one search index. So…

Model 1 + Model 2 => AggregatedIndex

This works great but Scout is also automatically making an index of Model 1 & Model 2 as well. So, I end up with 3 indexes…

AggregatedIndex
Model1Index
Model2Index

I only need the aggregate index. And creating the extra indexes is using up units ($$$). So, is there anyway to create an aggregate index (using scout extended with laravel) but without creating indexes for the models which are in the aggregate?

Thanks, Jonathan

I’m don’t think it’s currently supported by Scout + Scout Extended.

Looking at the code it seems that aggregator and regular indices don’t use the same observer. Can you try to disable syncing on your models and see if the aggregator still works?

Laravel\Scout\ModelObserver::disableSyncingFor(Customer::class);
Laravel\Scout\ModelObserver::disableSyncingFor(Subscription::class);

If it works, I’ll update the ScoutExtended docs.

Thank you!