ElasticSearch学习

文章40 |   阅读 18125 |   点赞0

来源:https://blog.csdn.net/ywl470812087/category_9621251.html

ElasticSearch查询返回信息根据字段排序(英文检索)

x33g5p2x  于2021-12-19 转载在 其他  
字(2.4k)|赞(0)|评价(0)|浏览(448)

根据年龄降序排序

#排序
GET /lib3/user/_search
{
  "query": {
    "match_all": {}
  },
  "sort":[
    {"age": {"order" :"desc"}}
  ]
}
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 5,
    "max_score" : null,
    "hits" : [
      {
        "_index" : "lib3",
        "_type" : "user",
        "_id" : "1",
        "_score" : null,
        "_source" : {
          "name" : "zhaoliu",
          "address" : "hei long jiang sheng tie ling shi",
          "age" : 50,
          "birthday" : "1970-12-12",
          "interests" : "xi buan hejiu, duanlian, lvyou"
        },
        "sort" : [
          50
        ]
      },
      {
        "_index" : "lib3",
        "_type" : "user",
        "_id" : "5",
        "_score" : null,
        "_source" : {
          "name" : "zhangsan",
          "address" : "bei jing chao yang qu",
          "age" : 29,
          "birthday" : "1988-10-12",
          "interests" : "xi huan tingyinyue , changge , tiaowu"
        },
        "sort" : [
          29
        ]
      },
      {
        "_index" : "lib3",
        "_type" : "user",
        "_id" : "4",
        "_score" : null,
        "_source" : {
          "name" : "wangwu",
          "address" : "bei jing hai dian qu qing he zhen",
          "age" : 26,
          "birthday" : "1995-10-12",
          "interests" : "xi huan biancheng, tingyinyue, lvyou"
        },
        "sort" : [
          26
        ]
      },
      {
        "_index" : "lib3",
        "_type" : "user",
        "_id" : "3",
        "_score" : null,
        "_source" : {
          "name" : "lisi",
          "address" : "bei jing hai dian qu qing he zhen",
          "age" : 23,
          "birthday" : "1998-10-12",
          "interests" : "xi huan hejiu,duanlian, changge"
        },
        "sort" : [
          23
        ]
      },
      {
        "_index" : "lib3",
        "_type" : "user",
        "_id" : "2",
        "_score" : null,
        "_source" : {
          "name" : "zhaoming",
          "address" : "bei jing hai dian qu qing he zhen",
          "age" : 20,
          "birthday" : "1998-10-12",
          "interests" : "xi huan hejiu, duanlian, changge"
        },
        "sort" : [
          20
        ]
      }
    ]
  }
}

相关文章