Reputation: 1
I am wondering if there is anyway to force FieldNameTranslator to append language to the field name.
query = context.GetQueryable<SearchResultItem>(i => i[context.Index.FieldNameTranslator.GetIndexFieldName("Catalog Number")].Contains("m0202"));
The code above turns into solr query:
https://localhost:8983/solr/sitecore_web_index/select?q=catalog_number_t:(*m0202*)
which returns 0 results.
If I append _en to the field name:
https://localhost:8983/solr/sitecore_web_index/select?q=catalog_number_t_en:(*m0202*)
I am getting expected results.
So how can I add it through the code?
Even
context.Index.FieldNameTranslator.GetIndexFieldName("catalog_number_t_en")
returns catalog_number_t
Catalog Number - single-line text field in sitecore. I am using Sitecore 9.1 Update-1, Solr 7.2.1.
Upvotes: 0
Views: 425
Reputation: 3283
If you have a culture language version stored in a different field name in a Solr index then you can use one of the following overloads in order to append the culture to the end of the field name:
string SolrFieldNameTranslator.GetIndexFieldName(string fieldName, CultureInfo culture);
string SolrFieldNameTranslator.GetIndexFieldName(string fieldName, Type returnType, CultureInfo culture);
Upvotes: 1