diff --git a/server/src/main/java/org/elasticsearch/index/mapper/GeoPointFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/GeoPointFieldMapper.java index eae0dcf7efad1..121b0eb0da2b4 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/GeoPointFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/GeoPointFieldMapper.java @@ -9,6 +9,7 @@ import org.apache.lucene.document.LatLonDocValuesField; import org.apache.lucene.document.LatLonPoint; +import org.apache.lucene.document.ShapeField; import org.apache.lucene.document.StoredField; import org.apache.lucene.geo.LatLonGeometry; import org.apache.lucene.index.LeafReaderContext; @@ -28,6 +29,7 @@ import org.elasticsearch.common.xcontent.support.MapXContentParser; import org.elasticsearch.geometry.Geometry; import org.elasticsearch.geometry.Point; +import org.elasticsearch.geometry.ShapeType; import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.plain.AbstractLatLonPointIndexFieldData; import org.elasticsearch.index.query.SearchExecutionContext; @@ -260,9 +262,17 @@ public Query geoShapeQuery(Geometry shape, String fieldName, ShapeRelation relat if (luceneGeometries.length == 0) { return new MatchNoDocsQuery(); } - Query query = LatLonPoint.newGeometryQuery(fieldName, relation.getLuceneRelation(), luceneGeometries); + final ShapeField.QueryRelation luceneRelation; + if (shape.type() == ShapeType.POINT && relation == ShapeRelation.INTERSECTS) { + // For point queries and intersects, lucene does not match points that are encoded to Integer.MAX_VALUE. + // We use contains instead. + luceneRelation = ShapeField.QueryRelation.CONTAINS; + } else { + luceneRelation = relation.getLuceneRelation(); + } + Query query = LatLonPoint.newGeometryQuery(fieldName, luceneRelation, luceneGeometries); if (hasDocValues()) { - Query dvQuery = LatLonDocValuesField.newSlowGeometryQuery(fieldName, relation.getLuceneRelation(), luceneGeometries); + Query dvQuery = LatLonDocValuesField.newSlowGeometryQuery(fieldName, luceneRelation, luceneGeometries); query = new IndexOrDocValuesQuery(query, dvQuery); } return query; diff --git a/server/src/test/java/org/elasticsearch/search/geo/GeoPointShapeQueryTests.java b/server/src/test/java/org/elasticsearch/search/geo/GeoPointShapeQueryTests.java index 2066921e0afb1..89a4551f3d3b0 100644 --- a/server/src/test/java/org/elasticsearch/search/geo/GeoPointShapeQueryTests.java +++ b/server/src/test/java/org/elasticsearch/search/geo/GeoPointShapeQueryTests.java @@ -34,7 +34,6 @@ protected void createMapping(String indexName, String fieldName, Settings settin client().admin().indices().prepareCreate(indexName).setMapping(xcb).setSettings(settings).get(); } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/75103") public void testFieldAlias() throws IOException { String mapping = Strings.toString(XContentFactory.jsonBuilder() .startObject()