为了在ElasticSearch中进行排序,找不到字段的映射 [英] No mapping found for field in order to sort on in ElasticSearch

查看:193
本文介绍了为了在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆