I was porting a SQL query on ElasticSearch.
The query needs to substitute an IN
clause.
Following this link I implemented the IN
this way:
{
"size": 1,
"query": {
"constant_score": {
"filter": {
"bool": {
"must": [
{
"terms": {
"products.flights.legs.hops.hopFlight.airlineId": [
"ib",
"lh"
]
}
}
]
}
}
}
}
}
It is working but probably I have a special case: you see, the hops field in the document is an array, so for a flight with one stop we have two hops.
In that case this query works even when just one of the two hops has ib or lh. It matches a document even when only one of the two hops has one of the airlines and the other hop is a different airline, not include in my terms.
I actually want to return only documents that, as airlineId, have only ib or lh or a combination of both.
Is it possible to do it?