ElasticSearch不会排序 [英] ElasticSearch won't sort

查看:221
本文介绍了ElasticSearch不会排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的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屋!

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