#community-help

Handling Facets and Translations in Document Search

TLDR gab wanted help on searching faceted translation-related documents. Kishore Nallan advised using separate, dedicated fields for each translatable property.

Powered by Struct AI

1

Oct 12, 2021 (27 months ago)
gab
Photo of md5-8be2a24edf7a95c9c74abce4b1130c3e
gab
12:50 PM
Hi,

would you mind giving me an advice about handling facets and translations?

I would like to acheive the following goals. I will have a document that has a country which has many translation.

Goal 1- I would like to be able to filter on this country field with any language (ex: in an autocomplete).
Goal 2- I would like to be able to create a faceted search where one of the criterias will be the country. Let's say the country would be a multiselect picker.
When the user select a country, I would filter the facets using the country id.

Should I then create as much as faceted country field I have translation ?
plus,
Should I create then a dedicated field to store the country id to be able to filter without taking care of the language?

document fields:
[
    {name:'country-en-US', facet:true},
    {name:'country-fr-CH', facet:true},
    {name:'country-it-IT', facet:true},
    {name:'country-id', facet:false},
]

Thanks for help
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
12:55 PM
Any reason for not creating 1 collection per country?
gab
Photo of md5-8be2a24edf7a95c9c74abce4b1130c3e
gab
12:58 PM
Ah, sorry I gave bad explanations. I'm indexing a warehouse entity that has one country. So I'm flattening the country inside the warehouse document to be able to performs search on this document. Then the single country has many translations.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:02 PM
The above schema looks good. You can filter by a particular country ID and then you can apply facet on one or more language fields.
gab
Photo of md5-8be2a24edf7a95c9c74abce4b1130c3e
gab
01:05 PM
Ok thanks, I was mainly curious about ways to handling translations. So it seems for any translatable property of my entity, I should add a dedicated field in my document.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
01:20 PM
Yes that's the best way to go about it since you will want to search it independently.

1