org.elasticsearch.index.query.GeoShapeQueryBuilder Java Examples
The following examples show how to use
org.elasticsearch.index.query.GeoShapeQueryBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElasticsearchIndex.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected Iterable<? extends DocumentResult> geoRelationQuery(String relation, IRI geoProperty, Shape shape, Var contextVar) throws MalformedQueryException, IOException { ShapeRelation spatialOp = toSpatialOp(relation); if (spatialOp == null) { return null; } final String fieldName = toGeoShapeFieldName(SearchFields.getPropertyField(geoProperty)); GeoShapeQueryBuilder fb = QueryBuilders.geoShapeQuery(fieldName, ElasticsearchSpatialSupport.getSpatialSupport().toShapeBuilder(shape)); fb.relation(spatialOp); QueryBuilder qb = QueryBuilders.matchAllQuery(); if (contextVar != null) { qb = addContextTerm(qb, (Resource) contextVar.getValue()); } SearchRequestBuilder request = client.prepareSearch(); SearchHits hits = search(request, QueryBuilders.boolQuery().must(qb).filter(fb)); return Iterables.transform(hits, new Function<SearchHit, DocumentResult>() { @Override public DocumentResult apply(SearchHit hit) { return new ElasticsearchDocumentResult(hit, geoContextMapper); } }); }