Setup
- Solr version:7.7
- Drupal Core version:9.4.7
- Search API version:1.2.7
- Search API Solr version:4.2.9
- Configured Solr Connector:
Issue
We recently upgraded our search_api_solr version from 4.2.7 to 4.2.9. While our regression tests passed , we later found out that the size of the index went up from 3G to 64GB and the indexing speed fell down drastically. The difference that we can see is that previously the SOLR document from Drupal would have something like
<field name="tm_X3b_en_FIELD_NAME">some text</field>
But the newer document after 4.2.9
<field name="tm_X3b_en_FIELD_NAME">some text</field>
<field name="tm_X3b_en_X2d_us_FIELD_NAME">some text</field>
<field name="tm_X3b_en_X2d_gb_FIELD_NAME">some text</field>
<field name="tm_X3b_fr_X2d_fr_FIELD_NAME">some text</field>
<field name="tm_X3b_ja_X2d_jp_FIELD_NAME">some text</field>
... so on for all languages , across all text fields
i.e. All the languages we have configured in Drupal get added as fields to the indexed document. Note that we do have many languages that are configured in Drupal , and all of those can potentially have content created (en-US, en-CA, en-FR, en-CountryCode since content can be localized to a country) - But we dont know why the module seems to take en fields and copy it over to all of these fields. If our document used to have 10 fields we now have 10*number of languages , all with the same content. Also since languages like French and Japanese have their own grammatical rules , it is not correct to copy over english text into those fields - however we dont know if this was by design or is a bug
This seems to be related to https://www.drupal.org/project/search_api_solr/issues/3303882
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | 3318813.patch | 8.77 KB | mkalkbrenner |
Comments
Comment #2
mkalkbrennerPlease enable search_api_solr_devel and help debugging this issue. We need to take a look how an entity gets indexed
My assumption is that you use Search API's language with fallback processor which wasn't supported in earlier module versions. If you use it, than these additional fields are correct.
Comment #3
dshetty commentedDevel is enabled on our development environments, what do you want us to check ?
Can you indicate what you mean by the language fallback processor ? We do use a language with fallback field , but previously our assumption is that it does whatever it needs to do at query time. I didnt see a processor of this name in the Processors page. The sm_fallback_language field is populated with all of our supported languages if thats what you mean.
Can you explain how this is intended to work ? Say we enable en , ja-jp and fr-fr and we translate some but not all of our content. So a ja-jp user would expect to see some Japanese and some English results. If you send an en node for indexing , the text in say title is getting also copied as a ja-jp field ? Why ? Previously our fallback was based at runtime on the query - the ja-jp user would see results in en or ja-jp ( but not fr-fr) - however at index time the en document would have only en fields and ja-jp would only have ja-jp
One of our issues is that because we can have localized English (not necessarily a translation but regulatory content) we have 150 odd languages which makes the problem severe for us but even if i limit to the above 3 languages , i cant see the reasoning behind it.
Comment #4
dshetty commentedFrom Solr Devel , I have attached the same node indexed on 4.2.8 v/s 4.2.9 of search_api_solr
Comment #5
mkalkbrennerIf en is declared as fallback for en_gb, the fulltext fields will be stored as en and en_gb with the same content.
The reason is that both field types might be configured differently.
That is the case if you declare en as fall back for fr, because a content is not yet translated from English to French.
And that's for what this Search API feature is designed for!
The feature is not suitable for language derivates like en_gb, en_us, ...
There's a different fallback mechanism built-in, where en is used for these.
So my suggestion is to simply turn off the language fallback field.
Comment #6
mkalkbrennerComment #7
mkalkbrennerComment #8
dshetty commentedI think I see what you are trying to do but again it looks wrong for precisely the reason you specify (
The reason is that both field types might be configured differently.) - If you have a fr-fr field type or a ja-jp field type with different settings (As they must be for different languages) , copying english text into those fields doesnt work right ? You can see why this is wrong if you put japanese characters into english fields right?
Also I would like to understand how you expect the query to work - there is a checkbox that states limit results to only this language or not . For those that have it as not , they would anyway already be querying the "en" fields and the "fr-fr" fields . We use fall back for query time
So en document ==> all en fields populated
fr-fr document ==> all fr-fr fields populated
At query time we can say give all documents matching the "en", "fr-fr" ,"en-fr" fields
It looks like you expect
en document ==> all en , en-fr, fr-fr (supported fields populated
fr-fr document ==> only fr-fr populated
At query time you expect to specify only fr-fr or only en-fr or only en right ?
Comment #9
mkalkbrennerFeel free to provide patches for a better implementation.
I agree that Japanese characters in a French field might lead to no results.
But that's an extreme edge case.
But in the other cases, if you don't provide the other fields a filter for fr will lead to zero results because the en_* fallback won't be used.
If you limit your search for fr only fr_* fulltext fields will be searched. So you must index English as French be providing the additional fields.
Indexing English as French is a fallback mechanism Search API provides and Search API Solr needs to deal with it.
Again, in your case that fallback feature is not appropriate and should be turned off.
And there's an additonal setting where you can limit the language specific fields to only configured ones.
Comment #10
mkalkbrennerAnother approach could be to index these fallbacks as langauge undefinded (und). That would lead to less fields and maybe better results.
But that would require to include language undefinded in queries like "fr OR und".
So we need an option to "index fallback as undefined". The additional filter already exists as an option and might be suitable.
Comment #11
mkalkbrennerI added a new option to index all fallback languages as undefined. Can you test it?
Comment #12
mkalkbrennerI missed the auto aggregated fulltext fields.
Comment #13
dshetty commented>Feel free to provide patches for a better implementation
>But in the other cases, if you don't provide the other fields a filter for fr will lead to zero results because the en_* fallback won't be used.
Im still trying to wrap my head around what works better so Im far away from a patch. In our case we have a million records which are in English and which will always be in English (Scientific data, Drupal custom entities) - but we also have the traditional content which will be translated. For us the replication of the fields into languages killed both disk and performance and indexing speed. But if I exclude such scenarios
>Again, in your case that fallback feature is not appropriate and should be turned off.
Im trying to understand this feedback - We do have a fallback since not everything is translated. Our current design uses sm_language_fallback.
Node1 (say en only) - sm_language_fallback =>en, fr-fr, en-fr i.e. this record is a candidate for everyone since nothing else exists
Node2_en => sm_language_fallback => en i.e. this record is a candidate only explicitly for en
Node2_en_fr => sm_language_fallback => en_fr,fr_fr i.e. this record is a candidate for both en-fr and fr-fr since no fr-fr exists
Node3_en => sm_language_fallback => en i.e. this record is a candidate only explicitly for en
Node3_en_fr => sm_language_fallback => en_fr i.e. this record is a candidate for only en-fr only
Node3_fr_fr => sm_language_fallback => fr_fr i.e. this record is a candidate for fr-fr only
i.e. in our case , we populate the fallback field with what the content applies to. The index however only has the field populated
when we query for a French user we will search the _en, _en-fr, _fr-fr fields (hooked into alterQuery) with a fq (facet) value of sm_language_falbback:en_fr if say the user had selected en-fr as their language(or fr-fr if the user had selected french). So we do not miss any search records , and we show the right precedence. So in the example above
a en-fr user sees Node1, Node2_en_FR and Node3_en_fr and (fq=sm_language_fallback:en-fr)
a fr-fr user sees Node1, Node2_en_FR and Node3_fr_fr and (fq=sm_language_fallback:fr-fr)
We cant turn off the fallback , nor can we restrict the languages (en_fr and fr-fr are both valid and so both would have to be checked right)
Comment #14
mkalkbrennerDid you try my patch?
It doesn't touch the language fallback field, just the language-specific fulltext fields.
Comment #15
mkalkbrennerComment #17
mkalkbrennerI set this feature request to fixed for the upcoming release.
@dshetty please provide some feedback if the new option solves your issue.
Comment #18
dshetty commented@mkalkbrenner
Not yet , will try to do it this week
Comment #19
freddy rodriguezI have a similar behavior. This is the list related with "title" in the solr collection index:
"tm_X3b_en_title":["walid wajih freij"],
"sort_X3b_en_title":["walid wajih freij"],
"sort_X3b_und_title":["walid wajih freij"],
But the search api is looking for: tm_X3b_und_name
This is the error in the dblog:
{ "error":{ "metadata":[ "error-class","org.apache.solr.common.SolrException", "root-error-class","org.apache.solr.common.SolrException"], "msg":"undefined field tm_X3b_und_name", "code":400}}
Because of the error described in: https://www.drupal.org/project/search_api_solr/issues/3218868 I had to activate the option: "Retrieve results for this site only". I dont know if this behavior could be related.
----------
After some testing, this option fixed the problem in my case (scenario of non multilingual site):
in the index configuration:
Limit to current content language.
Limit all search results for custom queries or search pages not managed by Views to current content language if no language is specified in the query.
Comment #20
freddy rodriguezComment #21
mkalkbrennerDon't post on closed issues. Open a new one.