繁体   English   中英

在弹性搜索中对嵌套文档进行排序

[英]sorting nested documents in elastic search

我在弹性搜索文档中有2个字段的嵌套字段:

blog = Nested(
    properties={
        'id': Integer(),
        'rating': Integer()
    }
)

ES文档包含博客列表:blog1,blog2等。

我希望所有文件的blob.id = x并在对应于该blob的评级字段上排序。 在没有排名脚本的情况下使用弹性搜索查询执行此操作是否可行? 请指教。

这样的事情应该可以满足您的需求:

{
  "query": {
    "nested": {
      "path": "blog",
      "query": {
        "term": {
          "blog.id": 123
        }
      }
    }
  },
  "sort": [
    {
      "blog.rating": {
        "order": "asc",
        "nested_path": "blog",
        "nested_filter": {
          "term": {
            "blog.id": 123
          }
        }
      }
    }
  ]
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM