gpt4 book ai didi

elasticsearch - 用Elasticsearch过滤

转载 作者:行者123 更新时间:2023-12-03 00:59:12 24 4
gpt4 key购买 nike

我想获取具有特定ID的日期范围,但是我的结果是在其中包含其他ID。我需要检查查询的帮助。

这就是试图做的

抓取 uniqueid == 1的所有文档,然后
开始范围从2016-10-11T12:00:30.000Z
到“2016-10-12T12:00:30.000Z”

我的查询和结果如下所示。

查询

GET _search

{
"query": {
"constant_score": {
"filter": {
"bool": {
"must": [
{
"term": {
"uniqueid": 1
}
}
],
"should": [
{
"range": {
"start": {
"from": "2016-10-11T12:00:30.000Z",
"to": "2016-10-12T12:00:30.000Z"
}
}
}
]
}
}
}
}
}

结果
  {
"took": 15,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 6,
"max_score": 1,
"hits": [
{
"_index": "cdr",
"_type": "face",
"_id": "AVfDCsC-vh94Tg1hrkix",
"_score": 1,
"_source": {
"start": "2016-10-12T12:00:30.000Z",
"answer": "2016-10-12T12:00:25.000Z",
"end": "2016-10-12T12:00:35.000Z",
"duration": 50,
"billsec": 55,
"uniqueid": 1,
"is_successful": true,
"is_clicked": true
}
},
{
"_index": "cdr",
"_type": "face",
"_id": "AVfDCucPvh94Tg1hrkiy",
"_score": 1,
"_source": {
"start": "2016-10-12T12:00:30.000Z",
"answer": "2016-10-12T12:00:25.000Z",
"end": "2016-10-12T12:00:35.000Z",
"duration": 50,
"billsec": 55,
"uniqueid": 2,
"is_successful": true,
"is_clicked": true
}
},
{
"_index": "cdr",
"_type": "face",
"_id": "AVfDC1G2vh94Tg1hrkiz",
"_score": 1,
"_source": {
"start": "2016-10-13T12:00:30.000Z",
"answer": "2016-10-13T12:00:25.000Z",
"end": "2016-10-13T12:00:35.000Z",
"duration": 50,
"billsec": 55,
"uniqueid": 2,
"is_successful": true,
"is_clicked": true
}
},
{
"_index": "cdr",
"_type": "face",
"_id": "AVfDC2IGvh94Tg1hrki0",
"_score": 1,
"_source": {
"start": "2016-10-13T12:00:30.000Z",
"answer": "2016-10-13T12:00:25.000Z",
"end": "2016-10-13T12:00:35.000Z",
"duration": 50,
"billsec": 55,
"uniqueid": 1,
"is_successful": true,
"is_clicked": true
}
},
{
"_index": "cdr",
"_type": "face",
"_id": "AVfDCCOOvh94Tg1hrkiv",
"_score": 1,
"_source": {
"start": "2016-10-10T12:00:15.000Z",
"answer": "2016-10-10T12:00:25.000Z",
"end": "2016-10-10T12:00:35.000Z",
"duration": 25,
"billsec": 25,
"uniqueid": 1,
"is_successful": true,
"is_clicked": true
}
},
{
"_index": "cdr",
"_type": "face",
"_id": "AVfDCR2Uvh94Tg1hrkiw",
"_score": 1,
"_source": {
"start": "2016-10-11T12:00:15.000Z",
"answer": "2016-10-11T12:00:25.000Z",
"end": "2016-10-11T12:00:35.000Z",
"duration": 25,
"billsec": 25,
"uniqueid": 1,
"is_successful": true,
"is_clicked": true
}
}
]
}
}

最佳答案

您需要删除网址路径下方的空行

GET _search
<--- remove this line
{
"query": {

像这样:
GET _search
{
"query": {

关于elasticsearch - 用Elasticsearch过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40043060/

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