Hello elastic gurus, I am pretty new to the whole stack and some help would be much appreciated. So I have this query running pretty often and it eats A LOT of resources. It works as intended results wise but I just want to know if you would have any advice how to make it any better!
GET cdr/_search
{
"query":{
"constant_score":{
"filter":{
"bool":{
"should":[
{
"range":{
"startTime":{
"gte":"2017-01-21T23:00+02:00",
"lte":"2017-01-21T23:50+02:00"
}
}
},
{
"range":{
"stopTime":{
"gte":"2017-01-21T23:00+02:00",
"lte":"2017-01-21T23:50+02:00"
}
}
},
{
"bool":{
"must":[
{
"range":{
"startTime":{
"lte":"2017-01-21T23:00+02:00"
}
}
},
{
"range":{
"stopTime":{
"gte":"2017-01-21T23:50+02:00"
}
}
}
]
}
}
],
"must":[
{
"term":{
"sourceIp":{
"value":"XX.XX.X.XX"
}
}
}
]
}
}
}
}
}
Sorry for the bad formatting. Anyway, so the first part of the query is pretty simple and is used to get all the documents in the provided date range and the second bool is used to get all the documents that crosses the provided range but is not exactly in it (for example documents that have 2017-01-21T22:59+02:00 as startTime and 2017-01-21T23:59+02:00 as stopTime). The last step is to get only those documents that are associated with particular client (IP address). The data types are startTime DATE, stopTime DATE, sourceIp KEYWORD. Any ideas how I could make this better? The total data size on disk is around 50 TB if that plays any role.