【问题标题】:Sitecore Solr query: field name translation culture issueSitecore Solr 查询:字段名称翻译文化问题
【发布时间】:2019-05-10 18:50:12
【问题描述】:

我想知道是否有强制 FieldNameTranslator 将语言附加到字段名称。

query = context.GetQueryable<SearchResultItem>(i => i[context.Index.FieldNameTranslator.GetIndexFieldName("Catalog Number")].Contains("m0202"));

上面的代码变成了solr查询:

https://localhost:8983/solr/sitecore_web_index/select?q=catalog_number_t:(*m0202*)

返回 0 个结果。

如果我将 _en 附加到字段名称:

https://localhost:8983/solr/sitecore_web_index/select?q=catalog_number_t_en:(*m0202*)

我得到了预期的结果。

那么如何通过代码添加呢?

偶数

context.Index.FieldNameTranslator.GetIndexFieldName("catalog_number_t_en")

返回 catalog_number_t

目录编号 - sitecore 中的单行文本字段。 我正在使用 Sitecore 9.1 Update-1、Solr 7.2.1。

【问题讨论】:

    标签: c# solr sitecore


    【解决方案1】:

    如果您将文化语言版本存储在 Solr 索引中的不同字段名称中,则可以使用以下重载之一将文化附加到字段名称的末尾:

    string SolrFieldNameTranslator.GetIndexFieldName(string fieldName, CultureInfo culture);
    string SolrFieldNameTranslator.GetIndexFieldName(string fieldName, Type returnType, CultureInfo culture);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-11-10
      • 2012-03-30
      • 2020-03-21
      • 1970-01-01
      • 2012-12-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多