I have this query in Elasticsearch 1.4.4:
`GET my_jobs/type_job/_search
{ "fields": [
"id","user","state","start_time","end_time"
],
"query": {
"bool": {
"must": [
{"term": {"user": {"value": "oid:user:id"}}},
{"term": {"id": {"value": "oid:job:301:7544:1"}}}
],
"must_not": [
{"term": {"state": {"value": "queued"}}},
{"term": {"queue": {"value": "desktop.q"}}}],
"should": [
{"bool": {
"must": [
{"term": {"state": {"value": "finished"}}},
{"range": {"start_time": {"lt": 1460930400}}},
{"range": {"end_time": {"gt": 1459461600}}}]
}},
{"bool": {
"must": [
{"term": {"state": {"value": "started"}}},
{"range": {"start_time": {"lt": 1460930400}}}]}}
]
}
}
}
But I am obtaining this:
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 8.948642,
"hits": [
{
"_index": "my_jobs",
"_type": "type_job",
"_id": "oid:job:301:7544:1",
"_score": 8.948642,
"fields": {
"id": [
"oid:job:301:7544:1"
],
"state": [
"finished"
],
"start_time": [
1460980655
],
"end_time": [
1460982464
],
"user": [
"oid:user:id"
]
}
}
]
}
}
But in my opinion this is not working correctly because this condition does not true:
"should": [
{"bool": {
"must": [
{"term": {"state": {"value": "finished"}}},
{"range": {"start_time": {"lt": 1460930400}}},
{"range": {"end_time": {"gt": 1459461600}}}]
}},
and
"start_time": [ 1460980655 ] > 1460930400 and not "start_time": [ 1460980655 ] < 1460930400 how we specify in the query at the begining.