Model Import problem

When i import my model data it’s works fine in laravel but when i import second model data it’s replace by first one.I want my full database data import in a single index. please help

Hi,

Do you index everything in one index by overriding the searchableAs method?

Currently, Scout maps the database primary key with Algolia objectID so if 2 models have the same primary key, which is very likely, one will override the other.

You might be able to change the primary key of your project
https://laravel.com/docs/5.5/eloquent#eloquent-model-conventions

If that’s too heavy, you extend the AlgoliaEngine class and change the behavior so you rely on a custom attribute instead of objectID.
https://www.algolia.com/doc/api-client/laravel/extending-scout/?language=laravel#extending-algolias-driver

Please, let me know if that worked for you.

Thanks sir it works but my purpose has not been solved because.

i want to my laravel project full database data import in one indices and i wand to create a central search box like as laravel home page search box.

Please some suggest me …i am beginner developer.

Thank you,
Alamgir Hossain

Please provide more details about what you have already setup.

I would recommend to not put everything in the same index and create a search experience where you display results depending on their type. Try the search of this website for instance. A “user” result should probably not be displayed the same way as a “thread” result.

sir thanks for your co-operation.
sir i want to create a central search box in a view page. when i type some thing this value search to every endices . That means full database search within a single search box.

If you choose to implement your search in the frontend, using instantsearch for instance, you can query multiple indices at once (like we do on this site). In the end, it will send multiple http queries but the user won’t see the difference.

i want same this which you say now…But how can i implement this please give me some suggestion
.