I have maintained one array of objects field which contains several objects, having two keys each but different values for those keys in each object and i want to run a range query along with a match_phrase query on each object but what is happening right now is that if a key is matched via match_phrase in 1st object and an other key is matched via the range query of 2nd object then both appear in result but i want to run both the queries respectively for each object.
1st POST request:
POST test/_doc
{
"name": "yash",
"score": [
{
"model" : "swift",
"score" : 5
},
{
"model" : "alto",
"score" : 6
},
{
"model" : "xuv",
"score" : 9
}
]
}
Search Query:
GET test/_search
{
"query": {
"bool": {
"must": [
{
"match_phrase": {
"score.model": "swift"
}
},
{
"range": {
"score.score": {
"gte": 6,
"lte": 9
}
}
}
]
}
}
}
Actual Result:
"_index" : "test",
"_type" : "_doc",
"_id" : "g1LA12wBeamdnjKY5k-N",
"_score" : 1.287682,
"_source" : {
"name" : "yash",
"score" : [
{
"model" : "swift",
"score" : 5
},
{
"model" : "alto",
"score" : 6
},
{
"model" : "xuv",
"score" : 9
}
]
}
Expected Result:
Nothing as the range of score in swift is not according to the specified value.