# Geo\_shape vs geo\_point performance

**URL:** <https://discuss.elastic.co/t/geo-shape-vs-geo-point-performance/9890>\
**Category:** Elasticsearch\
**Created:** [November 29, 2012, 4:08pm UTC](https://discuss.elastic.co/t/geo-shape-vs-geo-point-performance/9890 "2012-11-29T16:08:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![massfords](https://avatars.discourse-cdn.com/v4/letter/m/e47c2d/32.png) [@massfords](https://discuss.elastic.co/u/massfords)\
**Post date:** [November 29, 2012, 4:08pm UTC](https://discuss.elastic.co/t/geo-shape-vs-geo-point-performance/9890/1 "2012-11-29T16:08:13Z")

</div>

I'm interested in using the pre-indexed shape feature. In my case, I  
anticipate that the geo\_shape values for the documents will in fact be a  
point, but in order to benefit from the pre-indexed shape feature, I need  
to map them to geo\_shape as opposed to geo\_point.

The test consists of 5 documents:

- 2 documents with a geo\_point field
- 2 documents with a geo\_shape field with a point
- 1 document with both

In all cases, I'm searching with a polygon that has approximate 300 points.  
Note the big disparity in the times below.

Tests are as follow:

- geo\_shape filter with pre-indexed shape matches the geo\_shape docs in  
~ _8700 millis_
- geo\_shape filter with the shape defined inline matches geo\_shape  
docs in ~ _8600 millis_
- geo\_polygon filter with the polygon defined inline matches the  
geo\_point fields in ~ _2 millis_.

I'm using the \_cached=true and running the queries multiple times but get  
similar results each time.

Any thoughts on why there's such a big disparity between the two types? I

--

---

<div class="post-metadata">

**Author:** ![Jeffrey\_Gerard](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@Jeffrey\_Gerard](https://discuss.elastic.co/u/Jeffrey_Gerard)\
**Post date:** [November 30, 2012, 5:39am UTC](https://discuss.elastic.co/t/geo-shape-vs-geo-point-performance/9890/2 "2012-11-30T05:39:09Z")

</div>

Greetings,  
The geo\_shape and geo\_point types use drastically different mechanisms for  
querying. Quite simply the geo\_point method is more efficient, since it is  
optimized for documents that only use points; the geo\_shape queries are  
doing lots of extra work, assuming that they need to find 2-dimensional  
shapes (which is not true in your test).

I assume your query polygon is pretty large? You will get significantly  
faster geo\_shape queries by setting a smaller tree\_levels setting when you  
create the mapping. The defaults are 24 for the default "geohash" tree and  
12 for the "quadtree", so try cutting these in half. The spatial extent of  
your query is inversely related to the optimal choice of tree\_levels.

Even after optimizing tree\_levels, the geo\_point queries will probably  
always remain faster. The best bet might be to lobby for the developers to  
add an analogue to pre-indexed searches for geo\_points.

In the meantime, if you do have success around optimizing tree\_levels,  
please share your findings and query extents with the group here!

On Thursday, November 29, 2012 8:08:13 AM UTC-8, massfords wrote:

> I'm interested in using the pre-indexed shape feature. In my case, I  
> anticipate that the geo\_shape values for the documents will in fact be a  
> point, but in order to benefit from the pre-indexed shape feature, I need  
> to map them to geo\_shape as opposed to geo\_point.
> 
> The test consists of 5 documents:
> 
> - 2 documents with a geo\_point field
> - 2 documents with a geo\_shape field with a point
> - 1 document with both
> 
> In all cases, I'm searching with a polygon that has approximate 300  
> points. Note the big disparity in the times below.
> 
> Tests are as follow:
> 
> - geo\_shape filter with pre-indexed shape matches the geo\_shape docs  
> in ~ _8700 millis_
> - geo\_shape filter with the shape defined inline matches geo\_shape  
> docs in ~ _8600 millis_
> - geo\_polygon filter with the polygon defined inline matches the  
> geo\_point fields in ~ _2 millis_.
> 
> I'm using the \_cached=true and running the queries multiple times but get  
> similar results each time.
> 
> Any thoughts on why there's such a big disparity between the two types? I

--

---

<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:** [July 6, 2017, 3:02am UTC](https://discuss.elastic.co/t/geo-shape-vs-geo-point-performance/9890/3 "2017-07-06T03:02:04Z")

</div>


