Apply language-dependent search analyzer at search time


#1

Hello,

I'd like to archive the following: Based on a users language, a different search analyzer should be used on every field with a certain pattern (language_fieldname*).
I could archive this defining a search analyzer on query time.
However, as I search across many fields using the query string query, this would result in using this analyzer for every field but for some fields the analyzer defined by its mapping should be used.

Is there a solution to solve this problem? Is there maybe a way to define different search analyzers for the same field and I could search on the field "language_fieldname_de" for German users and "language_fieldname_fr" for French users without having to actually use two fields (which would work, but i'd have to store every field for every possible language).

The reason for this request is the usage of translation synonyms: On index-time, only one language should be indexed and translation synonyms should be resolved language dependent on query time.

Thanks in advance,
Jul


(Zachary Tong) #2

So there are a couple approaches:

  • You can analyze the same field with different language analyzers. You can define per-language multi-fields for the field, then at search time set the search_analyzer. As you noted, this'll create an extra copy for each additional language

  • You can just adjust the search_analyzer at search time, even if the field wasn't indexed with that analyzer. The results that come back may be...poor, since the analyzers don't match.

  • Use multiple queries, where each query applies the appropriate analyzer (either default or overridden) for the field(s) that it is querying.

It basically boils down to different combinations of using search-time search_analyzer and index-time analysis with multiple fields.

The DefGuide talks more about languages, particularly about using multiple languages per-document vs per-field vs mixed fields.


(system) #3

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