CIRCLE geometry is not supported

HELLO ,
I was using elasticsearch 6.1 before and i was able to query geo_shape LINESTRING using circle intersects . recently updated to 6.6 and unable to query the Same , How do I search for line string which is near to a point , below is my query
GET way/_search
{

"query":
{
"bool": {
"must":
{
"match_all":{}
}
,"filter": {

    "geo_shape": {
      "geometry": {
        "shape": {
          "type": "circle",
          "coordinates": [25.292679,55.4118288],
          "radius":10
        }
      }
    }
  }
}

}
}

it gives error like below,
{
"error": {
"root_cause": [
{
"type": "query_shard_exception",
"reason": "failed to create query: {\n "bool" : {\n "must" : [\n {\n "match_all" : {\n "boost" : 1.0\n }\n }\n ],\n "filter" : [\n {\n "geo_shape" : {\n "geometry" : {\n "shape" : {\n "type" : "circle",\n "radius" : "10.0m",\n "coordinates" : [\n 25.292679,\n 55.4118288\n ]\n },\n "relation" : "intersects"\n },\n "ignore_unmapped" : false,\n "boost" : 1.0\n }\n }\n ],\n "adjust_pure_negative" : true,\n "boost" : 1.0\n }\n}",
"index_uuid": "7kFB6PsbR0CPtnXsgOLO6Q",
"index": "way"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "way",
"node": "7x3HJTAjSPukxRwfrtuLZQ",
"reason": {
"type": "query_shard_exception",
"reason": "failed to create query: {\n "bool" : {\n "must" : [\n {\n "match_all" : {\n "boost" : 1.0\n }\n }\n ],\n "filter" : [\n {\n "geo_shape" : {\n "geometry" : {\n "shape" : {\n "type" : "circle",\n "radius" : "10.0m",\n "coordinates" : [\n 25.292679,\n 55.4118288\n ]\n },\n "relation" : "intersects"\n },\n "ignore_unmapped" : false,\n "boost" : 1.0\n }\n }\n ],\n "adjust_pure_negative" : true,\n "boost" : 1.0\n }\n}",
"index_uuid": "7kFB6PsbR0CPtnXsgOLO6Q",
"index": "way",
"caused_by": {
"type": "unsupported_operation_exception",
"reason": "CIRCLE geometry is not supported"
}
}
}
]
},
"status": 400
}

what will be the solution , i cannot see any doc says this CIRCLE SEARCH is obsolute.

Please help,

Which version are you using, 6.6.0 or 6.6.1?

Could you share as well your current geo_shape mapping?

Can you share your index mapping? and a sample document?

PUT way
{

"settings" : {
"number_of_shards" : 1,
"refresh_interval": "10s",
"number_of_replicas": 0
},
"mappings": {
"doc": {
"properties": {
"geometry": {
"type": "geo_shape"
},
"properties": {
"enabled": false,
"properties": {
"area_name": {
"type": "text"
},
"area_nm_tr": {
"type": "text"
},
"country_name": {
"type": "text"
},
"country_nm_tr": {
"type": "text"
},
"emirate_name": {
"type": "text"
},
"emirate_nm_tr": {
"type": "text"
},
"st_nm_tr": {
"type": "text"
},
"fr_spd_lim": {
"type": "float"
},
"interinter": {
"type": "text"
},
"link_id": {
"type": "float"
},
"manoeuvre": {
"type": "text"
},
"mod_val": {
"type": "text"
},
"ramp": {
"type": "text"
},
"roundabout": {
"type": "text"
},
"speed_cat": {
"type": "text"
},
"st_name": {
"type": "text"
},
"to_spd_lim": {
"type": "float"
}
}
},
"type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}

}

THANK YOU , this is my version
{
"name" : "7x3HJTA",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "3dDbeVmUTF23lReUj9szdA",
"version" : {
"number" : "6.6.0",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "a9861f4",
"build_date" : "2019-01-24T11:27:09.439740Z",
"build_snapshot" : false,
"lucene_version" : "7.6.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}

I dont have this isssue with 6.1 or 6.3 versions.

In 6.6 a new indexing strategy was introduced based on Lucene's BKD tree and a decomposition of polygons into triangles:

This strategy has been made the default and unfortunely it does not support filtering by distance yet. Therefore If you need such functionality you can just off the strategy to your mapping:

{
    "mappings": {
        "doc": {
            "properties": {
                "location": {
                    "type": "geo_shape",
                    "strategy" : "recursive"
                }
            }
        }
    }
}

Thank you . Its worked .

Special :-
I have the same issue of finding polygonal search with more vertices polygon . there I introduced polygon tiled into many squares and imported those , elastic-search , it give high precision search now.i

How do you deal with this the other way round, when the mapped item is a point (strictly, a geo_shape which is a point) and the query is a geo_shape containing a circle (using relation: within), which used to work before 6.6?

I am not sure I understand your question @frankshad. If you are indexing only points I would considered mapping it to a geo_point. Otherwise if you want to use geo_shape, the workaround above should work as well.

I am searching for locations within a radius of the stored point, so the circle is in the query, not the stored data. (I already reindexed everything for 6.6, not realising circle was no longer supported).

Are you saying if I use geo_point not geo_shape in the mapping, circle will be recognized in the query? Or ditto if I add strategy recursive to the mapping, even though the the circle is in the query? I was expecting I wold have to add strategy to the query in this case (though part of the reason for re-indexing everything was to take advantage of the new triangles method).

e.g mapping:

{
    "address": {
        "type": "nested",
	    "dynamic": "strict",
        "properties": {
            "location": {
                "type": "geo_shape" // only ever contains a point
            },
            ...
       }
      ...
}

and eg query:

{"query":
   {"nested":{"path":"address",
     "query":{"geo_shape":{"address.location":
        {"relation":"within","shape":
          {"type":"circle",
           "coordinates": [-2.519474029541,51.47063764119], "radius":"500m"}
        }}}}}}

If you are only indexing points I would recommend to use a geo_point field:

https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html

To be able to filter by distance you have a specialise query for that:

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html

Thanks, but that only works for the simple case I illustrated - there is a more complicated one which I also use, for hits within a given distance of a path. In that case it isn't just a circle, but a series of rectangles (determined by trigonometry from the line segments) and circles (at the ends and corners). (My third case which is inside a polygon, still works of course)

I guess I could do a bool search for the circles and the rectangles separately, though that's a fairly significant change to the code.

I think that's what I had better do, rather than going backwards to the older strategy which will get removed sometime anyway. Even though it means re-indexing again.

Thanks for sharing your use case. One benefit you should see when indexing them as geo_points is that indexing should be much faster, the index size smaller and hopefully queries will be faster although this will depend on how many boolean queries you need to perform (still I think it will be faster).

One thing I can recommend is to open a feature request in the Elasticsearch repository to support such queries for geo_points.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.