Geo search returns no results in es6.7

I'm mapping congressional districts in elasticsearch but my efforts are returning no results when trying to query by geo shape. Here's some relevant data:

The mapping:

	"mappings":{
	"house":{
		"properties":{
			"state_name":{
				"type":"text"
			},
			"district":{
				"type":"integer"
			},
			"shape":{
				"type":"geo_shape",
				"strategy":"recursive"
			}
		}
	}

An example of a WKT on the shape property: POLYGON((-122.612285 37.815224,-122.501272 37.821212,-122.499764 37.819724,-122.41871 37.852491,-122.418673 37.852505,-122.430183 37.918425,-122.432283 37.929824,-122.373982 37.883884,-122.373782 37.883725,-122.28246 37.709309,-122.28178 37.70823,-122.419802 37.708231,-122.420082 37.708231,-122.440893 37.716405,-122.440999 37.716488,-122.428203 37.731851,-122.428038 37.732016,-122.451147 37.731567,-122.453411 37.731568,-122.463399 37.752981,-122.463433 37.753028,-122.469667 37.738505,-122.470597 37.737665,-122.512732 37.735087,-122.578294 37.733988,-122.584728 37.779156,-122.588174 37.789362,-122.612285 37.815224))

My search query in kibana that is clearly inside that WKT:

GET /house/_search
{
"query":{
    "bool": {
        "must": {
            "match_all": {}
        },
        "filter": {
            "geo_shape": {
                "shape": {
                    "shape": {
                        "type": "circle",
                        "coordinates" : [-122.421151, 37.758442],
                        "radius": "100m"
                    }
                }
            }
        }
    }
}

I've also tried geo shape type point with intersects and contains relation (which is not currently supported). Logically, it seems like circles with radii querying for polygons match the strategy of intersects best which is why I started trying that effort, but I had no luck.

What else can I do to debug why these documents are not being found?

Hey.

is it possible, that you share a full reproduction including the JSON you indexed?

Also have you tried with a more recent version of Elasticsearch like 7.3, as there have been some improvements going on.

--Alex

Alex,

Is it possible to export the data from elasticsearch to show in detail? I'm extracting it from a mySQL database and inserting it into elasticsearch in the same step, I don't have an intermediate JSON that I directly touch but I could potentially create one if that's the only way.

I'm using the AWS elasticsearch service, so es6.7 is my highest available version. Happy to test on another provider that supports 7.x if you know of one, but I'm trying to avoid administering another raw linux server if I can avoid it.

Thanks for your help

If you know the id of the document you can simply retrieve it by its id, using the Get API, which contains all the JSON.

You can try Elasticsearch as a Service directly from the company who also writes the software (Elastic), see https://www.elastic.co/cloud/ - with the advantage of being able to always use the latest release as soon as it is out (disclaimer: I work there as well).

--Alex

Thanks Alex, I realized my issue:

I realized that my mapping was incorrect. I was manually setting a geo_shape mapping on shape but when my indexes were created they were creating Shape (note capitalization change) properties with type text. Thus none of my indexes had any geo_shape data to search.

The most useful thing I used to debug and find this issue was a readout of the GET /house/mapping data which showed the two distinct properties that should have been a single property.

1 Like