How should I manage the multi-language indexes (For example: page / page_translations models should become page_en / page_fr indexes). I am using "Dimsav\Translatable" package.
Page model: id, status_id, created_at, updated_at
PageTranslation model: id, page_id, locale, title, slug, body
Algolia offers support for this (https://www.algolia.com/doc/guides/search/multilingual-search/) but I am not sure how to achieve this with Laravel Scout.
The only solution that comes in my mind is to index both language rows (from the translations model) in the same index storing the locale and applying a condition on search.
Algolia
objectID=1, title='English title', locale_id='1'
objectID=2, title='Franch title', locale_id='2'
$pages = App\PageTranslation::search('Star Trek')->where('locale_id', 1)->get();
Or maybe a better approach? Maybe to index page / page_translations separately and search in both?
I would like to achieve something like:
pages_en index : objectID=1, title='English title', etc.
pages_fr index : objectID=2, title='Franch title', etc.
$pages = App\Page::search('Star Trek')->where('locale', 'en')->get();