Skip to content

GEO: intersects search for geo_shape return wrong result #49017

@happyjoblzp

Description

@happyjoblzp

Linestring intersect with polygon return wrong results!

Bug reappear method:

1、Create index use restful API like this, add insert two data:

curl -H "Content-Type: application/json" -XPUT 'http://localhost:9200/example' -d '
{
   "mappings": {
       "properties": {
           "location": {
               "type": "geo_shape"
           }
       }
   }
}
'

curl -H "Content-Type: application/json" -XPOST 'http://localhost:9200/example/_doc?refresh' -d '
{
    "name": "mytest1",
    "location" : {
        "type" : "polygon",
        "coordinates" : [
            [ [5, 5], [10, 6], [10, 10], [5, 10], [5, 5] ]
        ]
    }
}
'

curl -H "Content-Type: application/json" -XPOST 'http://localhost:9200/example/_doc?refresh' -d '
{
    "name": "qingdao",
    "location" : {
        "type" : "polygon",
        "coordinates" : [
            [ [6, 6], [9, 6], [9, 9], [6, 9], [6, 6] ]
        ]
    }
}
'

2、Use intersects to search, It returns only one piece of data(In fact, both data meet the spatial intersect with the linestring)

curl -H "Content-Type: application/json" -XGET 'http://localhost:9200/example/_search' -d '
{
    "query":{
        "bool": {
            "must": {
                "match_all": {}
            },
            "filter": {
                "geo_shape": {
                    "location": {
                        "shape": {
                            "type": "linestring",
                            "coordinates" : [ [0, 0], [5, 5], [7, 7] ]
                        },
                        "relation": "intersects"
                    }
                }
            }
        }
    }
}
'

{"took":1,"timed_out":false,"_shards":{"total":1,"successful":1,"skipped":0,"failed":0},"hits":{"total":{"value":1,"relation":"eq"},"max_score":1.0,"hits":[{"_index":"example","_id":"4zx-Y24BTFMtLEcLyvV6","_score":1.0,"_source":
{
    "name": "mytest1",
    "location" : {
        "type" : "polygon",
        "coordinates" : [
            [ [5, 5], [10, 6], [10, 10], [5, 10], [5, 5] ]
        ]
    }
}
}]}}

I don't know why miss polygon [ [6, 6], [9, 6], [9, 9], [6, 9], [6, 6] ]?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions