How does laravel scout define multiple indexes?

for example, in a laravel project, one table is product, and the other is article,. I want to use full-text search in all projects, but scout only allows you to define an index, or Synchronize

.

I have seen a lot of cases on the Internet. I hope you can provide ideas

.
Apr.11,2021

I have the same problem. Have you solved it?


to implement multiple model queries, you can change the configured index during model initialization.
for example, when using the ElasticSearch driver, the driver package defaults to taking the configuration value of scout.elasticsearch.index as the index, so by changing this configuration value in the _ _ construct method of the model, you can realize the multi-model query


override the searchableUsing method in the searchAble in the Model to be called, and update the custom index.

Menu