未找到字段的映射以在 ElasticSearch 中进行排序 [英] No mapping found for field in order to sort on in ElasticSearch
问题描述
如果发现某些文档不包含排序条件中使用的字段,则 Elasticsearch 在解析查询时会抛出 SearchParseException
.
Elasticsearch throws a SearchParseException
while parsing query if there are some documents found not containing field used in sort criteria.
SearchParseException: 解析失败 [未找到 [price] 的映射以进行排序]
SearchParseException: Parse Failure [No mapping found for [price] in order to sort on]
如何才能成功搜索这些文档,即使有些文档缺少 price
字段?
How can I successfully search these documents, even if some are missing the price
field?
推荐答案
在挖掘更多之后,我找到了下面给出的解决方案.ignore_unmapped
应该在 sort 子句中显式设置为 true
.
After digging more, I found the solution as given below. ignore_unmapped
should be explicitly set to true
in the sort clause.
"sort" : [
{ "rating": {"order" : "desc" , "ignore_unmapped" : true} },
{ "price": {"order" : "asc" , "missing" : "_last" , "ignore_unmapped" : true} }
]
有关更多信息,请查看 Elasticsearch 参考资料:
For further information have a look at the Elasticsearch references for:
这篇关于未找到字段的映射以在 ElasticSearch 中进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!