Geo_shape sort


(Halleystar) #1

my mapping is like following. I create index using it In the case of 1.7 and 5.6.4. but is has a different result. The result is following:

  1. in the case of elasticsearch1.7
{
	"took": 5,
	"hits": {
		"total": 2,
		"max_score": 1,
		"hits": [{
			"_index": "gis-region",
			"_type": "region",
			"_id": "4",
			"_score": 1,
			"_source": {
				"id": 470,
				"region": {
					"coordinates": [
						[
							["116.434225", "39.975287"],
							["116.449568", "39.995107"],
							["116.43970170867237", "39.99497761177407"],
							["116.41369680731", "39.994408212752"],
							["116.41369689850515", "39.99443664024678"],
							["116.394484", "39.993918"],
							["116.39572144035283", "39.99167941863296"],
							["116.40043", "39.983206"],
							["116.40043011431644", "39.98319769105138"],
							["116.40052165971491", "39.98321634473732"],
							["116.40052", "39.983323"],
							["116.40094644633666", "39.98330290109479"],
							["116.401634", "39.983443"],
							["116.410042", "39.981093"],
							["116.414031", "39.975205"],
							["116.434225", "39.975287"]
						]
					],
					"type": "polygon"
				}
			}
		}, {
			"_index": "gis-region",
			"_type": "region",
			"_id": "41",
			"_score": 1,
			"_source": {
				"id": 472,
				"region": {
					"coordinates": [
						[
							["116.414246", "39.975163"],
							["116.41421538644542", "39.97520574872182"],
							["116.414031", "39.975205"],
							["116.41078942906539", "39.979989750479554"],
							["116.4099886912492", "39.9811078995676"],
							["116.40550358152854", "39.98236146853092"],
							["116.40159620813535", "39.98343529936638"],
							["116.400484", "39.983069"],
							["116.400664", "39.974665"],
							["116.414246", "39.975163"]
						]
					],
					"type": "polygon"
				}
			}
		}]
	}
}
  1. the result in the case of 5.6.4
{
	"hits": {
		"total": 1,
		"max_score": 1,
		"hits": [{
			"_index": "gis-region",
			"_type": "region",
			"_id": "41",
			"_score": 1,
			"_source": {
				"id": 472,
				"region": {
					"coordinates": [
						[
							["116.414246", "39.975163"],
							["116.41421538644542", "39.97520574872182"],
							["116.414031", "39.975205"],
							["116.41078942906539", "39.979989750479554"],
							["116.4099886912492", "39.9811078995676"],
							["116.40550358152854", "39.98236146853092"],
							["116.40159620813535", "39.98343529936638"],
							["116.400484", "39.983069"],
							["116.400664", "39.974665"],
							["116.414246", "39.975163"]
						]
					],
					"type": "polygon"
				}
			}
		}]
	}
}`

The query DSL

    {
      "query" : {
        "geo_shape" : {
          "region" : {
            "shape" : {
              "type" : "point",
              "coordinates" : [
    			116.414235,
    			39.975154
              ]
            },
            "relation" : "intersects"
          }
        }
      }
    }

The mapping

    curl -X PUT 'http://127.0.0.1:9200/gis-region' -d '
  {
  	"mappings": {
  		"region": {
  			"properties": {
  				"id": {
  					"type": "long"
  				},
  				"region": {
  					"type": "geo_shape",
  					"tree": "geohash",
  					"precision": 26
  				}
  			}
  		}
  	}
  }

(Christoph) #2

Hi @halleystar,

I took the liberty to re-format your post a little using https://jsonlint.com/ to make it more readable.
To answer your question: using http://geojson.io, I can see the point you query with lies outside of
document 4, but right on the edge of document 41. So this was probably a bug that was fixed in after 1.7.

"_id" : "4"

"_id" : "41"


(Halleystar) #3

ok, thanks. I will validate again, because it have a very big impact for me. the other question, when i adjust the precision to make it return two document, The order is also different from which in 1.7


(system) #4

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