Dynamically assign filter, char_filter, analyzer?

Wanted to know if it's possible to dynamically assign filter, char_filter & analyzer?

We have multilanguage data in ES. The search is language specific which the application detects at request time. So if request is in English then I want to load the english synonym & stemmer filters + char_filter & analyzers. If in Chinese then load different ones, etc.

What is the best way to accomplish this? And should any defaults be set at index creation time?

If the application can detect the language, then why not get it to call specific analysers with something like search_analyzer | Elasticsearch Reference [7.10] | Elastic?

Would I need to set any default at index creation time (like maybe the english one) or use only search time analyzers in this case of lang specific ones since the recommendation mentions:

"Usually, the same analyzer should be applied at index time and at search time"

Ideally, yes. That comment is just making you aware there are trade offs and costs to the approaches.

One different approach is to have an index per language.

Ok thanks. Will go with search time analyzers + a default generic one.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.