@Override protected Query doToQuery(QueryShardContext shardContext) throws IOException { MappedFieldType fieldType = shardContext.fieldMapper(fieldName); if (fieldType == null) { if (ignoreUnmapped) { return new MatchNoDocsQuery(); } else { throw new QueryShardException(shardContext, "failed to find geo_point field [" + fieldName + "]"); } } if (!(fieldType instanceof GeoPointFieldType)) { throw new QueryShardException(shardContext, "field [" + fieldName + "] is not a geo_point field"); } QueryValidationException exception = checkLatLon(); if (exception != null) { throw new QueryShardException(shardContext, "couldn't validate latitude/ longitude values", exception); } if (GeoValidationMethod.isCoerce(validationMethod)) { GeoUtils.normalizePoint(center, true, true); } Query query = LatLonPoint.newDistanceQuery(fieldType.name(), center.lat(), center.lon(), this.distance); if (fieldType.hasDocValues()) { Query dvQuery = LatLonDocValuesField.newSlowDistanceQuery(fieldType.name(), center.lat(), center.lon(), this.distance); query = new IndexOrDocValuesQuery(query, dvQuery); } return query; }
@Override protected Query doToQuery(QueryShardContext shardContext) throws IOException { MappedFieldType fieldType = shardContext.fieldMapper(fieldName); if (fieldType == null) { if (ignoreUnmapped) { return new MatchNoDocsQuery(); } else { throw new QueryShardException(shardContext, "failed to find geo_point field [" + fieldName + "]"); } } if (!(fieldType instanceof GeoPointFieldType)) { throw new QueryShardException(shardContext, "field [" + fieldName + "] is not a geo_point field"); } QueryValidationException exception = checkLatLon(); if (exception != null) { throw new QueryShardException(shardContext, "couldn't validate latitude/ longitude values", exception); } if (GeoValidationMethod.isCoerce(validationMethod)) { GeoUtils.normalizePoint(center, true, true); } Query query = LatLonPoint.newDistanceQuery(fieldType.name(), center.lat(), center.lon(), this.distance); if (fieldType.hasDocValues()) { Query dvQuery = LatLonDocValuesField.newSlowDistanceQuery(fieldType.name(), center.lat(), center.lon(), this.distance); query = new IndexOrDocValuesQuery(query, dvQuery); } return query; }
@Override protected Query doToQuery(QueryShardContext shardContext) throws IOException { MappedFieldType fieldType = shardContext.fieldMapper(fieldName); if (fieldType == null) { if (ignoreUnmapped) { return new MatchNoDocsQuery(); } else { throw new QueryShardException(shardContext, "failed to find geo_point field [" + fieldName + "]"); } } if (!(fieldType instanceof GeoPointFieldType)) { throw new QueryShardException(shardContext, "field [" + fieldName + "] is not a geo_point field"); } QueryValidationException exception = checkLatLon(); if (exception != null) { throw new QueryShardException(shardContext, "couldn't validate latitude/ longitude values", exception); } if (GeoValidationMethod.isCoerce(validationMethod)) { GeoUtils.normalizePoint(center, true, true); } Query query = LatLonPoint.newDistanceQuery(fieldType.name(), center.lat(), center.lon(), this.distance); if (fieldType.hasDocValues()) { Query dvQuery = LatLonDocValuesField.newSlowDistanceQuery(fieldType.name(), center.lat(), center.lon(), this.distance); query = new IndexOrDocValuesQuery(query, dvQuery); } return query; }
QueryValidationException exception = checkLatLon(shardContext.indexVersionCreated().before(Version.V_2_0_0)); if (exception != null) { throw new QueryShardException(shardContext, "couldn't validate latitude/ longitude values", exception);