# Geo\_shape sort

**URL:** https://discuss.elastic.co/t/geo-shape-sort/139724
**Category:** Elasticsearch
**Created:** [July 12, 2018, 10:08am UTC](https://discuss.elastic.co/t/geo-shape-sort/139724 "2018-07-12T10:08:01Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![halleystar](https://avatars.discourse-cdn.com/v4/letter/h/9fc29f/32.png) [@halleystar](https://discuss.elastic.co/u/halleystar)
#### Post date: [July 12, 2018, 10:08am UTC](https://discuss.elastic.co/t/geo-shape-sort/139724/1 "2018-07-12T10:08:01Z")

</div>

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

```auto
{
	"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

```auto
{
	"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

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

```

The mapping

```auto
    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
  				}
  			}
  		}
  	}
  }

```

---

<div class="post-metadata">

### Author: ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)
#### Post date: [July 12, 2018, 1:09pm UTC](https://discuss.elastic.co/t/geo-shape-sort/139724/2 "2018-07-12T13:09:52Z")

</div>

Hi @halleystar,

I took the liberty to re-format your post a little using [https://jsonlint.com/](https://jsonlint.com/) to make it more readable.  
To answer your question: using [http://geojson.io](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_4](https://us1.discourse-cdn.com/elastic/original/3X/7/1/71a302317806bdc9efa66a7760085a281c3930ca.png)

"\_id" : "41"

 ![id_41](https://us1.discourse-cdn.com/elastic/original/3X/0/7/07a174b12806159f74db0b7e10bd2dabe2e615c4.png)

---

<div class="post-metadata">

### Author: ![halleystar](https://avatars.discourse-cdn.com/v4/letter/h/9fc29f/32.png) [@halleystar](https://discuss.elastic.co/u/halleystar)
#### Post date: [July 13, 2018, 1:53am UTC](https://discuss.elastic.co/t/geo-shape-sort/139724/3 "2018-07-13T01:53:51Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [August 10, 2018, 1:54am UTC](https://discuss.elastic.co/t/geo-shape-sort/139724/4 "2018-08-10T01:54:02Z")

</div>

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