gpt4 book ai didi

sql - Elasticsearchj存在和不存在的实现

转载 作者:行者123 更新时间:2023-12-02 23:03:09 25 4
gpt4 key购买 nike

Select COUNT(distinct name) 
From index1
Where date between X and y
And name in (Select name
From index1
Where date between p and s)

Elasticsearch中的等效查询?

最佳答案

The Filter Aggregation may be the answer.

像这样:

{
"size" : 0,
"query" : {
"filtered" : {
"query" : {
"match_all" : { }
},
"filter" : {
"range" : {
"date" : {
"from" : "2015-03-10T21:51:47.703-04:00",
"to" : "2015-03-20T21:51:47.727-04:00",
"include_lower" : true,
"include_upper" : true
}
}
}
}
},
"aggregations" : {
"names1" : {
"filter" : {
"range" : {
"date" : {
"from" : "2015-02-28T21:51:47.733-05:00",
"to" : "2015-03-20T21:51:47.734-04:00",
"include_lower" : true,
"include_upper" : true
}
}
},
"aggregations" : {
"names2" : {
"terms" : {
"field" : "name"
}
}
}
}
}
}

关于sql - Elasticsearchj存在和不存在的实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29176392/

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