Sorry for the confusing title.
I'm trying to build a query that searches either the game title or a unique id, but only return one result if a unique id is searched (and found).
For example, here is a search using the term "Portal 2". Portal 2 won't match any of the "ids.name" fields so it does a search in the "name" key and returns that game properly.
{
"index":"games",
"type":"game",
"body":{
"query":{
"bool":{
"should":[
{
"nested":{
"path":"ids",
"query":{
"term":{
"ids.name":{
"value":"Portal 2",
"boost":2
}
}
}
}
},
{
"match":{
"name":{
"query":"Portal 2"
}
}
}
]
}
}
}
}
And here is the same thing with the search term "portal-2-45218" which does an exact match on ids.name. It matches the first "should" query properly but also returns games found from the second query.
{
"index":"games",
"type":"game",
"body":{
"query":{
"bool":{
"should":[
{
"nested":{
"path":"ids",
"query":{
"term":{
"ids.name":{
"value":"portal-2-45218",
"boost":2
}
}
}
}
},
{
"match":{
"name":{
"query":"portal-2-45218"
}
}
}
]
}
}
}
}
How would i go about somehow stopping the search once an exact match from "ids.name" is found?