gpt4 book ai didi

Elasticsearch 按子文档中的字段排序

转载 作者:行者123 更新时间:2023-11-29 02:53:27 31 4
gpt4 key购买 nike

我有这样的文档:

{
"parent" : {
"properties" : {
"id": {
"type" : "keyword"
}
"name" : {
"type" : "keyword"
}
}
}
}

和子文档:

{
"child": {
"_parent": {
"type": "parent"
},
"_routing": {
"required": true
},
"properties": {
"child_id": {
"type" : "keyword"
},
"child_name" : {
"type" : "keyword"
},
"child_time": {
"type": "date"
}
}
}
}

我如何根据具有最新 child_time 的 child 的 child_name 对父文档进行排序?

最佳答案

我无法解释细节,因为我还不了解它们,但我找到了这个解决方法:

https://www.elastic.co/guide/en/elasticsearch/reference/5.0/query-dsl-has-child-query.html#_sorting

相应的功能请求已关闭,该功能请求将提供一种按子文档的值排序的显式方法: https://github.com/elastic/elasticsearch/issues/2917

关于Elasticsearch 按子文档中的字段排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41571512/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com