1) MY template for indices of type myindex-YYYY-MM-DD is -
PUT _template/myindex_template
{
"index_patterns" : ["myindex-*"],
"aliases" : {
"myindex_alias" : {}
},
"settings": {
"number_of_replicas": 2,
"number_of_shards": 2,
"analysis": {},
"refresh_interval": "1m",
"index.mapping.ignore_malformed": true
},
"mappings": {
"properties": {
"my_id" : {"type" : "long"},
"my_ts" : {"type": "date"},
"location1" : {"type": "geo_shape"},
"prev_my_ts" : {"type": "date"},
"prev_location1" : {"type": "geo_shape"}
}
}
} <---- Here my_id,my_ts gives uniqueness(mentioning for understanding purposes.
2) My Query is -->
GET /myindex_alias/_search
{
"size" : 0,
"query": {
"bool": {
"must": {
"range": {
"my_ts": {
"gte": "2020-06-05T00:00:59",
"lte": "2020-06-12T21:59:59"
}
}
},
"filter": {
"bool": {
"should": [
{
"bool": {
"must": [
{
"geo_shape": {
"location1": {
"indexed_shape": {
"index": "my_polygons",
"id": "mypoly_1",
"path": "polygon_shape"
},
"relation": "disjoint"
}
}
},
{
"geo_shape": {
"prev_location1": {
"indexed_shape": {
"index": "my_polygons",
"id": "mypoly_1",
"path": "polygon_shape"
},
"relation": "within"
}
}
}
]
}
},
{
"bool": {
"must": [
{
"geo_shape": {
"location1": {
"indexed_shape": {
"index": "my_polygons",
"id": "mypoly_1",
"path": "polygon_shape"
},
"relation": "within"
}
}
},
{
"geo_shape": {
"prev_location1": {
"indexed_shape": {
"index": "my_polygons",
"id": "mypoly_1",
"path": "polygon_shape"
},
"relation": "disjoint"
}
}
}
]
}
}
]
}
}
}
},
"aggs": {
"dist_id": {
"terms": {
"field": "my_id",
"size": 10000
}
}
}
}
-
Index my_polygons has predefined polygon - mypoly_1.
The query mentioned in 2) above, used to work fine in a bit earlier versions than 7.6.
I have millions of rows under myindex_alias related indices(each index is daily index) used in the query.
The query is trying to get unique list of my_id for a given time-range for cases where (location1 is inside polygon mypoly_1 and prev_location1 is outside) or the opposite.
Not sure why it does not give any results ( I am certain that it is supposed to give results).
Result is -
{
"took" : 13,
"timed_out" : false,
"_shards" : {
"total" : 98,
"successful" : 98,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 0,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
},
"aggregations" : {
"dist_id" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [ ]
}
}
}
`when it should be giving unique values if my_id (along with count for each)..``
I do not get any errors when I run the query. Is there some setting I am missing here? Has anything changed?? I am certain that same query worked in earlier versions of ES (including I think 7.4).
Please review. Thanks.