[英]Sitecore Solr Error undefined field tags
I am using Sitecore 8.1 with SOLR Search Provider.我将 Sitecore 8.1 与 SOLR 搜索提供程序一起使用。 When I perform a search I am getting error below:
当我执行搜索时,出现以下错误:
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))]
I believe the issue is that Sitecore API is somehow sending tags instead of tags_sm .我认为问题在于 Sitecore API 以某种方式发送标签而不是tags_sm 。 When I manually update this field on SOLR Admin Portal query string, it returns data.
当我在 SOLR 管理门户查询字符串上手动更新此字段时,它会返回数据。
Now the real question is why/how the Sitecore API is sending tags instead of tags_sm.现在真正的问题是 Sitecore API 为什么/如何发送标签而不是 tags_sm。 I had a look at schema.xml on web_index core, it has below:
我查看了 web_index 核心上的 schema.xml,它有以下内容:
<field name="_tags" type="string" indexed="true" stored="true" multiValued="true" />
Appreciate your help.感谢你的帮助。
For all fields starting with _
, Sitecore does not append suffixes (like _sm
).对于以
_
开头的所有字段,Sitecore 不会附加后缀(如_sm
)。 So the field in Solr will be _tags
(you should be able to confirm this with Luke).所以 Solr 中的字段将是
_tags
(你应该可以与 Luke 确认这一点)。
Check if your SearchResultItem
class (the one you pass to IQuerable
), has a property with [IndexField("tags")]
attribute and change it to [IndexField("_tags")]
.检查您的
SearchResultItem
类(您传递给IQuerable
的类)是否具有带有[IndexField("tags")]
属性的属性并将其更改为[IndexField("_tags")]
。
Also answering the other part of your question - you should never worry about what is the field name in Solr.同时回答你问题的另一部分——你永远不应该担心 Solr 中的字段名是什么。 Always use what is in Sitecore configuration for Sitecore built-in fields.
始终对 Sitecore 内置字段使用 Sitecore 配置中的内容。 And for your own fields, use their names lowercase.
对于您自己的字段,请使用小写的名称。 That's it.
而已。
I had a similar issue and the fix is to match the field type defined in the backend.我有一个类似的问题,解决方法是匹配后端定义的字段类型。 Ensure the code that triggers the search in C# has the right field type.
确保在 C# 中触发搜索的代码具有正确的字段类型。 In my case, I was trying to use ID type for tags when I switched it to Guid the name automatically suffixed with _sm while querying the index.
在我的例子中,当我将它切换到 Guid 时,我试图对标签使用 ID 类型,在查询索引时名称自动以 _sm 为后缀。 Also ensure using correct collection type List worked compared to IEnumerable.
与 IEnumerable 相比,还要确保使用正确的集合类型列表有效。
Side note the same code with field type as ID with IEnumerable worked in Lucene.旁注,在 Lucene 中,使用 IEnumerable 的字段类型作为 ID 的代码相同。
public class MySearchContentModel : SearchResultItem
{
[IndexField(BuiltinFields.LatestVersion)]
public bool IsLatestVersion { get; set; }
[IndexField("Tag")]
public List<Guid> Tag { get; set; }
}
The _sm tag will be added depending on the field type. _sm 标签将根据字段类型添加。 Check Sitecore.ContentSearch.Solr.DefaultIndexConfiguration and the elements in /sitecore/contentSearch/indexConfigurations/defaultSolrIndexConfiguration/FieldMap/typeMatches
检查 Sitecore.ContentSearch.Solr.DefaultIndexConfiguration 和 /sitecore/contentSearch/indexConfigurations/defaultSolrIndexConfiguration/FieldMap/typeMatches 中的元素
Here a list of ids are mapped to [fieldName]_sm in the typeName="guidCollection".这里的 id 列表映射到 typeName="guidCollection" 中的 [fieldName]_sm。 Check that your configuration has this "_sm" extension.
检查您的配置是否具有此“_sm”扩展名。 If it does you might want to check, that the map for "fieldNames" doesn't include the tags field name, so that it will not get the correct suffix.
如果是,您可能需要检查“fieldNames”的映射是否不包含标签字段名称,因此它不会获得正确的后缀。
If you change the config remember to rebuild the index.如果更改配置,请记住重建索引。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.