ElasticSearch不会排序 [英] ElasticSearch won't sort
问题描述
我的ElasticSearch查询与排序不排序:
My ElasticSearch query with sort doesn't sort:
{
"query": {
"match_all": {}
},
"sort": [
{
"id": {
"order": "desc"
}
}
]
}
添加 没有任何效果,除了现在每个结果都有一个额外的属性
Adding the "sort" doesn't have any effect except that every result now has an additional attribute
sort: [0]
看起来sort属性为0,因此结果的顺序不会改变。
It looks like the "sort" attribute is 0, therefore the order of the results doesn't change.
id是我索引中文档的实际属性。将其更改为idFOOBARthrows[没有为[idFOOBAR]找到映射以排序],所以似乎识别该属性。还尝试过其他属性,如userId等,相同的结果。
"id" is an actual attribute of the documents in my index. Changing it to "idFOOBAR" throws "[No mapping found for [idFOOBAR] in order to sort on]", so it seems to recognize the attribute. Also tried other attributes like "userId" etc., same outcome.
我错过了什么?
推荐答案
将属性映射从 index =no
更改为 index =not_analyzed
修正它。
Changing the attribute mapping from index="no"
to index="not_analyzed"
fixed it.
这篇关于ElasticSearch不会排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!