I'm migrating from ES1.7 to 7.17. Facing some issues with implementing filteredQuery
using Java Client API.
For example, in 1.7.5
QueryBuilder queryBuilder = QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(), FilterBuilders.inFilter("_id", someList);
Query generated from queryBuilder above:
{
"filtered" : {
"query" : {
"match_all" : { }
},
"filter" : {
"terms" : {
"_id" : [ "1", "2", "3" ]
}
}
}
}
Javadoc for filteredQuery -
A query that applies a filter to the results of another query.
Params: queryBuilder - The query to apply the filter to (Can be null)
filterBuilder - The filter to apply on the query (Can be null)
What I've tried so far is
Query.Builder queryBuilder = (Query.Builder) new Query.Builder()
.bool(bBuilder -> bBuilder
.must(MatchAllQuery.of(b -> b)._toQuery())
.filter(fBuilder -> fBuilder.ids(
idBuilder-> idBuilder.values(someList)
)
));
Query from Java client:
{
"bool": {
"filter": [
{
"ids": {
"values": [ "1", "2", "3" ]
}
}
],
"must": [
{
"match_all": { }
}
]
}
}
But this is not returning same result. Can someone please help with Java Client code if that is correct?