-
Hello, Depending on the active local of the site I would like to search on the I've tried multiple things following this guide (but it seems to work only if the translations keys are at the root level of the object, which is not the case here because they are contained inside Here is a sample of the code with instantsearch: const local = 'en'
// Not working
helper
.setQuery(helper.state.query)
.setSettings({ queryLanguages: [local] })
// or
.setQueryParameter("queryLanguages", [local])
.search()
// Also not working
helper
.setQuery(helper.state.query)
.setQueryParameter("searchableAttributes", [`translations.${local}`, `content.${local}`])
// or
.setQueryParameter("restrictSearchableAttributes", [`translations.${local}`, `content.${local}`])
.search() What would be the proper way of implementing a Multilingual search in this context ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
searchable attributes is a setting, not a query parameter, which is why that second doesn't work. Similarly in the first example, you're setting settings, which is done once per index, not per session, and not at the frontend. If you'd actually want to search differently, the best way to go is to create an index per language, that otherwise follows the same schema, so you can use the same frontend, just different indices. Otherwise restrictSearchableAttributes should indeed work, but it might not in the example you sent, because of passing searchableAttributes as a parameter instead of a setting. Hope that already helps, but more detailed help will be best given by contacting support@algolia.com, since this is irrelevant to InstantSearch itself. Have a nice day! |
Beta Was this translation helpful? Give feedback.
searchable attributes is a setting, not a query parameter, which is why that second doesn't work. Similarly in the first example, you're setting settings, which is done once per index, not per session, and not at the frontend.
If you'd actually want to search differently, the best way to go is to create an index per language, that otherwise follows the same schema, so you can use the same frontend, just different indices.
Otherwise restrictSearchableAttributes should indeed work, but it might not in the example you sent, because of passing searchableAttributes as a parameter instead of a setting.
Hope that already helps, but more detailed help will be best given by contacting support@algo…