/** * Create a new geohash filter for a given set of geohashes. In general this method returns a * boolean filter combining the geohashes OR-wise. * * @param context Context of the filter * @param fieldType field mapper for geopoints * @param geohash mandatory geohash * @param geohashes optional array of additional geohashes * @return a new GeoBoundinboxfilter */ public static Query create( QueryShardContext context, BaseGeoPointFieldMapper.GeoPointFieldType fieldType, String geohash, @Nullable List<CharSequence> geohashes) { MappedFieldType geoHashMapper = fieldType.geoHashFieldType(); if (geoHashMapper == null) { throw new IllegalArgumentException("geohash filter needs geohash_prefix to be enabled"); } if (geohashes == null || geohashes.size() == 0) { return geoHashMapper.termQuery(geohash, context); } else { geohashes.add(geohash); return geoHashMapper.termsQuery(geohashes, context); } }