Text Search in Multi-Lingual XWiki

We just noticed a very confusing behaviour concerning text search.

Our Wiki basically exclusively contains German langugage texts. However, as one of or foreign language employees wanted to translate some of the pages to English language, we enabled multi-language feature and she set her account’s default language to English.

So if there’s an English language version of a page, she will see this and otherwise the default German version is shown. So far, so good.

The search however only seems to consider pages in English language, not showing any matches in German texts eben though she sees those texts if she opens this page (as there is no English version of that page).

This renders the search basically useless in her case.

Is this intended? Shouldn’t the search index and return the contents which are actually presented to the user in the XWiki, instead of some subset only?

Or did we do something wrong?

The behaviour affects the text search box as well as page name autocompletion in the hypelink dialog, which is were we noticed it - the employee wanted to fix a broken link and just was not able to find the target page in the target page field…

Apparently, my previous post didn’t make it clear which behaviour I expected and why the behaviour I observed was confusing to me.

In short:


As a user, I’d expect the Search feature (in the page header) and the Autocomplete features (for creating page links etc.) to search exactly the same contents which I can see myself in the Wiki.

If my Wiki is configured to display language X, then I’ll see the translated version of pages which have such a translated version, and I’ll see all pages which do not in their default language. But I’ll see all of this content in the navigation tree, breadcrumb and so on.


However, this is not the content the Search and Autocomplete features will work on by default - both only will search pages which actually have a translation to language X and will simply ignore all the other content which I can see in the Wiki.

This also means that I will not be able to use auto-completion for creating links to pages which have not (yet) been translated…

According to XWiki professional support (Thanks for the quick reply!), this behaviour is actually intentional - even though I still don’t really understand in which case it may be the behaviour expected by the user. :wink:

In any case, the professional support pointed me to Loading... which describes this problem. The search behaviour can be adjusted with some code changes in some internal XWiki pages which implement the search and auto-suggest features.

Adjusting the search is described here:

https://jira.xwiki.org/browse/XWIKI-9977?focusedCommentId=79695&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-79695

Enabling this search behaviour for auto-completion apparently requires another change in

/xwiki/bin/edit/XWiki/SuggestSolrMacros

where the following two lines:

#if (!$filterNames.contains('locale'))
#set ($discard = $filterQuery.add("locale:(""$xcontext.locale"" OR """")"))

have to be changed to:

#if (!$filterNames.contains('locales'))
#set ($discard = $filterQuery.add("locales:(""$xcontext.locale"" OR """")"))

A third adjustment might be necessary somewhere, but I’m not yet sure about this. In any case, Search and Autocompletion work more as I’d expect with those adjustments applied.

I guess this should be added to the FAQ or Snippets documentations - would it be correctly located as an FAQ?

Some pages are sometimes found twice in the search, though. (I observed this with a page which only had a German language version as default language, and this single version of the page was listed twice in the Search results, once indicating locale “de” and once “de_DE” - strange…)

This is not would not be what I’d expect (There is only a single language version of this page, and as a user, I also see the page only once in the navigation tree, so why display the same translation of the same page twice in the search results?), but it’s still better than not being able to use Search and Autocomplete for a majority of pages in the first place…

The following JIRA issue provides more detailed explanations:

https://jira.xwiki.org/browse/XWIKI-16598

Hello Mr. Ohrner,

i have exactly the same problem.
we first had no multilingual
we imported several pages (there are in en)
we created pages (language set to de_DE)
we switched to multilanguage, default language is de_DE

no page content in de_DE Pages is found. I Have to translate a page to en and then words on the page are found

Ho do I edit Main.SolrSearch ?

What’s the best way to clean the mess ? We have Pages en, de_DE

The tool “default language updater” seems to update only pages with empty locales

You need to edit here: /xwiki/bin/edit/Main/SolrSearchMacros

Besides that, I’m no expert in Xwiki search and Xwiki internationalization / localization… However, the approach described above seems to work for us, even though we actually translated only very few pages in the end.