tschmidt01
(Thomas Schmidt)
April 24, 2024, 5:08am
1
Using the old java client you could create a geo bounding box query by just supplying a geohash like so:
QueryBuilders.geoBoundingBoxQuery("some-field")
.setCorners("some-geo-hash")
Was this feature removed from the new Java API Client as now you would have to either supply cords
, tlbr
, trbl
or wkt
instead?
dadoonet
(David Pilato)
April 24, 2024, 6:59am
2
Welcome!
Indeed. I can't see how to support Geo-bounding box query | Elasticsearch Guide [8.13] | Elastic with the Java Client.
@ltrotta Do you know?
ltrotta
(Laura Trotta)
April 24, 2024, 8:18am
3
Hey! I have written this query from the tutorial using the java client:
esClient.search(sr -> sr
.index("my_locations")
.query(q -> q
.bool(b -> b
.must(m -> m.matchAll(ma -> ma))
.filter(f -> f
.geoBoundingBox(g -> g
.field("pin.location")
.boundingBox(bb -> bb
.wkt(w -> w.wkt("BBOX (-74.1, -71.12, 40.73, 40.01)"))))))),Object.class);
The other options (cords,tlbr,trbl) can be set along with wkt as in this example.