Reputation: 31
How to make compound query, as example I need to find geojson data with some properties (these properties is set in search query) within some polygon?
I know there are the GeoPolygonQueryBuilder and the BoolQueryBuilder for these kind of requests, but how to use them together in a single request to fetch data from ES?
Thanks!
Upvotes: 1
Views: 75
Reputation: 265817
This is a shot in the dark, because your question is lacking a minimal, reproducible example or even pseudo-code. If you are asking how to write a query that combines two sub queries, use the BoolQueryBuilder
and provide multiple mandatory sub queries:
final BoolQueryBuilder query = new BoolQueryBuilder()
.must(new GeoPolygonQueryBuilder(
"geo_field",
List.of(new GeoPoint(14, 50), …)))
.must(new GeoPolygonQueryBuilder(
"geo_field",
List.of(new GeoPoint(14, 50), …)));
BoolQueryBuilder
has additional methods such as mustNot
, should
, or filter
.
Upvotes: 1