Search language

43 views
Skip to first unread message

Heike Franosch

unread,
Nov 11, 2024, 1:24:10 PMNov 11
to Magnolia User Mailing List
Hi all,

I use searchfn.searchPages, but the list of results contain excerpts in english as well as in german. So, combining the excerpt results in a mix of languages. It seems to be mainly the title/title_de property values of links and headline/headline_de of text and image.

How can I separate the languages correctly?

Thanks for any help,
Heike

Milan Divilek

unread,
Nov 14, 2024, 1:56:45 AMNov 14
to Magnolia User Mailing List, hfgm...@gmail.com
Hi Heike,
there are several ways how to do it: You can either  use separate indexes for different languages or you need to filter the query for the language you want to search in.

Separate indexes:
You would configure 2 indexers one for EN, another one for DE and different client for every of them. FieldMappings for EN one would use properties with english and fieldMappings for DE would have configured properties with _de suffix. 
Them for search you would use solrfn.query(queryTerm).clientName(<english-or-german-client>).search() and alternate the clientName for the one you want to search in.

Filter Query:
If queryTerm doesn't specify the field which should be used for search then it uses defaultField specified in your schema and this field is standardly composed of values from multiple fields. In Magnolia example configuration this default field is configured to "_text_" field and  almost all field are copied into it.
Here you can either specify filed(s) in query which should be used for search. solrfn.query("title_de":queryTerm OR "headline_de":queryTerm).search() this would search only in the title_de" and  "headline_de" fields.
Or you need to set what is copied into "defaultField" and have different copyFields(defaultField) for every language. See how to configure it in solr configuration - https://solr.apache.org/docs/8_7_0/solr-core/org/apache/solr/update/processor/CloneFieldUpdateProcessorFactory.html

Regards
Milan

Heike Franosch

unread,
Nov 22, 2024, 4:20:51 AMNov 22
to Magnolia User Mailing List
Thanks, this helped a lot understanding how it works :-)

Heike
Reply all
Reply to author
Forward
0 new messages