Я хочу получить диапазон дат с определенным идентификатором, но мой результат включает в себя другие идентификаторы. Мне нужна помощь в проверке запроса.Фильтр с elasticsearch
Это то, что я пытаюсь сделать
Fectch все документы, где 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
}
}
]
}
}
переместить запрос 'range' в массив' must'. а также использовать POST вместо GET при отправке полезной нагрузки. – Val
@Val Я пробовал это, все еще не работает – SimpiMind
Даже при использовании POST вместо GET? – Val