Hi everyone. I have Laravel app with Scout using t...
# community-help
d
Hi everyone. I have Laravel app with Scout using typesense driver and I am using spatie translatable package to store translatable data in json columns, for example, name column contains this: {"en": "en value", "es": "es title"} I can't figure out how to configure all of this to only search in current locale. Basically, when app locale is en and if I search with keyword "title", it should not find this record, but it does at the moment.
j
You want to set the query_by field dynamically to
name.en
for example depending on the locale chosen
You can set search parameters dynamically at search time like this: https://laravel.com/docs/11.x/scout#typesense-dynamic-search-parameters
d
Thank you, it works 👍
👍 1
@Jason Bosco Hi, another issue with this. At the moment few laravel models do not have any records For example, when importing data:
Copy code
php artisan scout:import \\App\\Models\\Project
All [\App\Models\Project] records have been imported.
And the search logic is setup to go through all models where I want to search and in these models where there are no records I get error: `Could not find a field named
title.en
in the schema` I am wondering if there is something in configuration I could change. Because at the moment only idea I have, is to filter these models by querying tables and getting record count in them. Thanks!
j
If you're using automatic schema detection, and there are no documents with the
title.en
field then it won't be created it in the collection schema by Typesense. So you want to make sure at least one document has that field, or alternatively, explicitly set that field in the collection schema
👍 1