Jason
Jason

Reputation: 683

How is ElasticSearch queried using the Java client?

The site only has documentation for JSON, but not the Java client. Is there some sort of mapping I should be performing?

For example geo location queries: http://www.elasticsearch.org/guide/reference/query-dsl/geo-distance-range-filter.html

How would such a query be written using the Java client?

Thanks Jason

Upvotes: 4

Views: 2901

Answers (1)

Karussell
Karussell

Reputation: 17375

Not obvious but not that complicated ;)

SearchRequestBuilder srb = client.prepareSearch(index);                
srb.setQuery(QueryBuilders.matchAllQuery());
srb.setFilter(FilterBuilders.geoDistanceRangeFilter("filter1").lat(1234).lon(4321).geoDistance(GeoDistance.PLANE) ..... );

Upvotes: 5

Related Questions