为了在ElasticSearch中进行排序,找不到字段的映射 [英] No mapping found for field in order to sort on in ElasticSearch
问题描述
如果有一些文档没有包含在排序条件中使用的字段,则Elasticsearch会在解析查询时抛出一个 SearchParseException
blockquote>
SearchParseException:解析失败[没有映射找到[价格]为了排序]
如何成功搜索这些文件,即使有些缺少价格
字段?
在挖掘更多之后,我找到了下面给出的解决方案。 ignore_unmapped 应该在sort子句中显式设置为 true
。
sort:[
{rating:{order:desc,ignore_unmapped:true}},
{price :{order:asc,missing:_last,ignore_unmapped:true}}
]
Elasticsearch throws a SearchParseException
while parsing query if there are some documents found not containing field used in sort criteria.
SearchParseException: Parse Failure [No mapping found for [price] in order to sort on]
How can I successfully search these documents, even if some are missing the price
field?
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中进行排序,找不到字段的映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!