Adding multiple backends with wagtail.search.backends.database results in index being overwritten with last in the list #9253
Labels
status:Unconfirmed
Issue, usually a bug, that has not yet been validated as a confirmed problem.
type:Bug
When creating multiple backends on a multi-language site, it turns out that the index is simply overwritten for each backend with the result that the last in the list is the one the site will be indexed with.
For example:
In the above example, the entire site will be indexed according to the Spanish dictionary and unaccenting/stemming rules.
If I create a page with the title “We are going walking in the mountains” with backends:
The indexed title will appear as expected with stop words omitted and stem words:
'go':3B 'mountain':7B 'today':8B 'walk':4B
Searching with the default (English) backend and the term ‘mountains’ returns the page.
With the same backends reversed in order:
'are':2B 'going':3B 'in':5B 'mountains':7B 'the':6B 'today':8B 'walking':4B 'we':1B
The stop words are no longer filtered nor words stemmed as they are being parsed by the Spanish backend.
Searching the term ‘mountains’ with the english backend produces no match.
When running update_index, I see the following:
So I would understand this means the default index is being rebuilt over and over for each backend which would explain why the last entry is the one the site is indexed by.
While it says default index, there is nothing in the documentation regarding creating multiple indexes.
Issues:
wagtail.search.backends.database
' backend needs to support multiple search configs.Perhaps supporting multiple search configs could be achieved by adding a column for the backend name with one row per
backend + observation
in thewagtailsearch_indexentry
table - searching with the backend 'es' for example would return results from rows that only match that backend name (this is not the same as filtering pages that match the locale, this is filtering the index to match the required search config). This would only work if the index was not rebuilt for each backend entry though. Alternatively, a separate index perWAGTAILSEARCH_BACKENDS
key or as specified in the config declaration.Wagtail: 3.03
Django: 4.0.2
Python: 3.10.6
The text was updated successfully, but these errors were encountered: