Hi,
I am not sure this is intended but when i play with bool->should queries it seems that the query gets really slow.
For my tests, i've made an index composed by 4 170 000 documents stored in 6 different types.
The full query :
{
"from": 0,
"size": 1,
"sort": [{
"_geo_distance": {
"geoloc": {
"lat": 39.9173,
"lon": 116.386
},
"order": "asc",
"unit": "km"
}
}],
"stored_fields": ["_type", "_id"],
"query": {
"bool": {
"must": [{
"match_all": {}
}, {
"geo_distance": {
"distance": "28km",
"geoloc": {
"lat": 39.9173,
"lon": 116.386
}
}
}],
"should": [
[{
"term": {
"_type": "1"
}
}, {
"geo_distance": {
"distance": "4km",
"geoloc": {
"lat": 39.9173,
"lon": 116.386
}
}
}],
[{
"term": {
"_type": "2"
}
}, {
"geo_distance": {
"distance": "4km",
"geoloc": {
"lat": 39.9173,
"lon": 116.386
}
}
}],
[{
"term": {
"_type": "3"
}
}, {
"geo_distance": {
"distance": "15km",
"geoloc": {
"lat": 39.9173,
"lon": 116.386
}
}
}],
[{
"term": {
"_type": "4"
}
}, {
"geo_distance": {
"distance": "28km",
"geoloc": {
"lat": 39.9173,
"lon": 116.386
}
}
}],
[{
"term": {
"_type": "5"
}
}, {
"geo_distance": {
"distance": "4km",
"geoloc": {
"lat": 39.9173,
"lon": 116.386
}
}
}],
[{
"term": {
"_type": "6"
}
}, {
"geo_distance": {
"distance": "28km",
"geoloc": {
"lat": 39.9173,
"lon": 116.386
}
}
}]
],
"minimum_should_match": 1,
"filter":
}
}
}
The behavior is really strange if i add the part of the query in bold or not.
Without the bold part i have :
{
"took" : 277,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 4170789,
"max_score" : null,
"hits" : [
{
"_index" : "dev_geopoints",
"_type" : "4",
"_id" : "288466",
"_score" : null,
"sort" : [
13.378053070482325
]
}
]
}
}
but when I add my "must" request a filter on the maximum radius used in the "should", i have :
{
"took" : 9,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 8,
"max_score" : null,
"hits" : [
{
"_index" : "dev_geopoints",
"_type" : "4",
"_id" : "288466",
"_score" : null,
"sort" : [
13.378053070482325
]
}
]
}
}
In ES 2.X i could use "and"/"or" operators in the filters section, but in ES 5.0 i cannot use "or" filters and i have to use "should". That slows the queries a lot.
Am i missing something ?
Thanks,
Alex