GeoDistanceCondition extends GeospatialCondition { @Override public Query doQuery(SpatialStrategy strategy) { BooleanQuery.Builder builder = new BooleanQuery.Builder(); builder.add(query(maxGeoDistance, strategy), FILTER); if (minGeoDistance != null) { builder.add(query(minGeoDistance, strategy), MUST_NOT); } return builder.build(); } GeoDistanceCondition(Float boost,
                                String field,
                                Double latitude,
                                Double longitude,
                                GeoDistance minGeoDistance,
                                GeoDistance maxGeoDistance); @Override Query doQuery(SpatialStrategy strategy); @Override MoreObjects.ToStringHelper toStringHelper(); final double latitude; final double longitude; final GeoDistance minGeoDistance; final GeoDistance maxGeoDistance; }
@Test public void testQueryMax() { Schema schema = schema().mapper("name", geoPointMapper("lat", "lon").maxLevels(8)).build(); GeoDistanceCondition condition = new GeoDistanceCondition(0.5f, "name", 90D, -180D, null, GeoDistance.parse("10hm")); Query query = condition.doQuery(schema); assertNotNull("Query is not built", query); BooleanQuery booleanQuery = (BooleanQuery) query; assertEquals("Query num clauses is wrong", 1, booleanQuery.clauses().size()); BooleanClause maxClause = booleanQuery.clauses().get(0); assertEquals("Query occur is wrong", BooleanClause.Occur.FILTER, maxClause.getOccur()); query = maxClause.getQuery(); assertEquals("Query type is wrong", IntersectsRPTVerifyQuery.class, query.getClass()); assertEquals("Query is wrong", "IntersectsVerified(fieldName=)", query.toString()); }