【发布时间】:2016-01-24 12:02:21
【问题描述】:
我正在使用带有 SOLR 搜索提供程序的 Sitecore 8.1。当我执行搜索时,出现以下错误:
2480 2016:01:24 21:29:14 ERROR Solr Error : ["undefined field tags"] - Query attempted: [((_basetemplates_sm:(13789a2000bc4f77a98f40d0a2f18738) AND
-standardvalue_b:(True)) AND ((title_t:(*smoking*))^9 OR (abstract_t:
(*smoking*))^0.200000002980232 OR (articlefulltext_s:
(*smoking*))^0.200000002980232 OR (title_t:(*be*))^9 OR (abstract_t:
(*be*))^0.200000002980232 OR (articlefulltext_s:(*be*))^0.200000002980232 OR
(tags:(d4426cf378c14a97be3459cd9bfe569b))^0.100000001490116))]
我认为问题在于 Sitecore API 以某种方式发送 tags 而不是 tags_sm。当我在 SOLR Admin Portal 查询字符串上手动更新此字段时,它会返回数据。
现在真正的问题是 Sitecore API 为什么/如何发送标签而不是 tags_sm。我查看了 web_index 核心上的 schema.xml,它有以下内容:
<field name="_tags" type="string" indexed="true" stored="true" multiValued="true" />
感谢您的帮助。
【问题讨论】:
-
这是您的自定义搜索查询吗?还是内置 Sitecore 查询?对于以
_开头的所有字段,Sitecore 不会附加后缀(如_sm)。所以 Solr 中的字段将是_tag(你应该能够与 Luke 确认这一点)。检查您的SearchResultItem类(您传递给 IQuerable 的类)是否具有具有[IndexField("tags")]属性的属性并在此处添加 undescore。 -
感谢@MarekMusielak,您的解决方案奏效了。我将属性从 tags 更新为 _tags 它起作用了!
-
顺便说一句,索引字段映射究竟是如何工作的,即我们如何判断是否以 _ 作为前缀。 SOLR如何决定要索引的字段的名称。
-
我已将评论更改为答案并添加了更多解释。