This is a story of 2 queries. One returns results, while the other does not. Why?
Query that returns results:
{
"index":"my_index",
"type":"places",
"body":{
"from":0,
"size":"12",
"sort":{
"_score":{
"order":"desc"
}
},
"query":{
"function_score":{
"query":{
"bool":{
"must":[
],
"should":[
],
"must_not":[
],
"filter":[
]
}
},
"functions":[
{
"gauss":{
"location":{
"origin":{
"lat":"41.243368",
"lon":"-116.79711"
},
"offset":"0mi",
"scale":"100mi"
}
}
}
],
"score_mode":"sum",
"boost_mode":"sum"
}
}
}
}
Query that does NOT return results:
{
"index":"my_index",
"type":"places",
"body":{
"from":0,
"size":"12",
"sort":{
"_score":{
"order":"desc"
}
},
"query":{
"function_score":{
"query":{
"bool":{
"must":[
],
"should":[
{
"terms":{
"region_id":[
32273
],
"boost":2
}
}
],
"must_not":[
],
"filter":[
]
}
},
"functions":[
{
"gauss":{
"location":{
"origin":{
"lat":"41.243368",
"lon":"-116.79711"
},
"offset":"0mi",
"scale":"100mi"
}
}
}
],
"score_mode":"sum",
"boost_mode":"sum"
}
}
}
}
The Bool Query has only a Should Clause.
Also, I am summing the scores, not multiplying them.
It's true that I do not have any items in the index that have the specified "region_id", but I fail to see how the results of the first query are excluded from the second query. It seems like the 0 score on the Bool Query is acting like a filter.