# Elasticsearch geo search strange behavior

**URL:** <https://discuss.elastic.co/t/elasticsearch-geo-search-strange-behavior/111059>\
**Category:** Elasticsearch\
**Created:** [December 11, 2017, 10:09am UTC](https://discuss.elastic.co/t/elasticsearch-geo-search-strange-behavior/111059 "2017-12-11T10:09:07Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![iandthen](https://avatars.discourse-cdn.com/v4/letter/i/919ad9/32.png) [@iandthen](https://discuss.elastic.co/u/iandthen)\
**Post date:** [December 11, 2017, 10:09am UTC](https://discuss.elastic.co/t/elasticsearch-geo-search-strange-behavior/111059/1 "2017-12-11T10:09:07Z")

</div>

A few days ago I faced with the strange behavior of geo search in Elasticsearch.

I use AWS managed ES 5.5, obviously over REST interface.

Assume we have 200k objects with location info represented as the point only. I use geo search to find the points within multiple polygons. They are shown on the image below. Coordinates were extracted from final request to the ES.

[![](https://i.stack.imgur.com/gIN26.jpg) ](https://i.stack.imgur.com/gIN26.jpg)

The request is built using official Java High-level REST client. The request query will be attached below.

I want to search for all objects within at least **one** polygon.  
Here is the query (real fields names and values were replaced by stub, **Except** location, and locationPoint.coordinates)

Query is here --\> [https://goo.gl/3W62kA](https://goo.gl/3W62kA)

**Note** , that field _location_ is mapped as _geo\_shape_ and field _location.coordinates_ is mapped as _geo\_point_.

**So the problem is next.** Below the results (hits count) of requests are presented. Only polygons are changing.

```
# Polygons Hits count

1) 1,2,3,4 5565

2) 1 4897

3) 3,4 75

4) 2 9

5) 1,3,4 5543

6) 1,2 5466

7) 2,3,4 84

```

So, if I add results of polygon 1st with 2,3,4 polygons I will not obtain the number as it was in full request.

For example, _#1 != #2 + #7_, also _#1 != #5 + #4_, **but** _#7 == #4 + #3_

I cannot understand whether it is the issue in this request or expected behavior or even bug in ES.

Can anyone help me to understand the logic of such ES behavior or point to the solution?

Thanks!

---

<div class="post-metadata">

**Author:** ![s1monw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/s1monw/32/3637_2.png) [@s1monw](https://discuss.elastic.co/u/s1monw)\
**Post date:** [December 15, 2017, 10:59am UTC](https://discuss.elastic.co/t/elasticsearch-geo-search-strange-behavior/111059/2 "2017-12-15T10:59:41Z")

</div>

can you replicate this issue with vanilla elasticsearch or with an instance running on elastic cloud [1]?. The AWS is not managed or run by us and it might run non-vanilla ES instances.

[1] [https://www.elastic.co/cloud](https://www.elastic.co/cloud)

---

<div class="post-metadata">

**Author:** ![iandthen](https://avatars.discourse-cdn.com/v4/letter/i/919ad9/32.png) [@iandthen](https://discuss.elastic.co/u/iandthen)\
**Post date:** [December 15, 2017, 11:16am UTC](https://discuss.elastic.co/t/elasticsearch-geo-search-strange-behavior/111059/3 "2017-12-15T11:16:53Z")

</div>

Hi Simon,

Unfortunately, I cannot do it due to the large amount of specific data that should not be copied anywhere except AWS.  
Are you talking about some fork of vanilla ES?  
AFAIK, Amazon provides vanilla ES just with some restrictions on settings and access to raw files.

---

<div class="post-metadata">

**Author:** ![s1monw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/s1monw/32/3637_2.png) [@s1monw](https://discuss.elastic.co/u/s1monw)\
**Post date:** [December 15, 2017, 11:26am UTC](https://discuss.elastic.co/t/elasticsearch-geo-search-strange-behavior/111059/4 "2017-12-15T11:26:19Z")

</div>

can you paste me the output of `http://yourelasticsearchip:9200`

---

<div class="post-metadata">

**Author:** ![s1monw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/s1monw/32/3637_2.png) [@s1monw](https://discuss.elastic.co/u/s1monw)\
**Post date:** [December 15, 2017, 11:27am UTC](https://discuss.elastic.co/t/elasticsearch-geo-search-strange-behavior/111059/5 "2017-12-15T11:27:15Z")

</div>

> [@iandthen](#):
>
> Unfortunately, I cannot do it due to the large amount of specific data that should not be copied anywhere except AWS.

yeah so [Elastic Cloud: Hosted Elasticsearch, Hosted Search | Elastic](https://www.elastic.co/cloud) runs on AWS as well.

---

<div class="post-metadata">

**Author:** ![iandthen](https://avatars.discourse-cdn.com/v4/letter/i/919ad9/32.png) [@iandthen](https://discuss.elastic.co/u/iandthen)\
**Post date:** [December 15, 2017, 11:29am UTC](https://discuss.elastic.co/t/elasticsearch-geo-search-strange-behavior/111059/6 "2017-12-15T11:29:47Z")

</div>

> [@s1monw](#):
>
> [http://yourelasticsearchip:9200](http://yourelasticsearchip:9200)

Here is the response:  
{  
"name": "zFHTplx",  
"cluster\_name": "889835723148:disco-es",  
"cluster\_uuid": "WtJtJkRdRpyzndcsF7-G4w",  
"version": {  
"number": "5.5.2",  
"build\_hash": "Unknown",  
"build\_date": "2017-10-18T04:35:01.381Z",  
"build\_snapshot": false,  
"lucene\_version": "6.6.0"  
},  
"tagline": "You Know, for Search"  
}

> yeah so [Elastic Cloud: Hosted Elasticsearch, Hosted Search | Elastic](https://www.elastic.co/cloud) runs on AWS as well.

I meant that I cannot do it due to security policies inside the company.

---

<div class="post-metadata">

**Author:** ![s1monw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/s1monw/32/3637_2.png) [@s1monw](https://discuss.elastic.co/u/s1monw)\
**Post date:** [December 15, 2017, 1:00pm UTC](https://discuss.elastic.co/t/elasticsearch-geo-search-strange-behavior/111059/7 "2017-12-15T13:00:17Z")

</div>

```auto
{
  "name" : "3E1A4vn",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "ZWnDTtaoQxiur9tlYaFslA",
  "version" : {
    "number" : "5.5.2",
    "build_hash" : "b2f0c09",
    "build_date" : "2017-08-14T12:33:14.154Z",
    "build_snapshot" : false,
    "lucene_version" : "6.6.0"
  },
  "tagline" : "You Know, for Search"
}

```

This is the repsonse from a vanilla 5.5.2 (see build hash and date). You are running a modified version of elasticsearch, I can't help you with your questions from AWS elasticsearch you need to get help there or replicate it on a vanilla version. I am sorry about that.

> I meant that I cannot do it due to security policies inside the company.

What policies are that I mean elastic cloud runs on the same infrastructure as the service that you are using.

---

<div class="post-metadata">

**Author:** ![iandthen](https://avatars.discourse-cdn.com/v4/letter/i/919ad9/32.png) [@iandthen](https://discuss.elastic.co/u/iandthen)\
**Post date:** [December 15, 2017, 2:01pm UTC](https://discuss.elastic.co/t/elasticsearch-geo-search-strange-behavior/111059/8 "2017-12-15T14:01:59Z")

</div>

Thank you for help. Will try to find solution on AWS discuss.

Have a nice day!

---

<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:** [January 12, 2018, 2:02pm UTC](https://discuss.elastic.co/t/elasticsearch-geo-search-strange-behavior/111059/9 "2018-01-12T14:02:15Z")

</div>

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