# An example of more simple pre-indexed shapes filtering and more complex ones not filtering

**URL:** <https://discuss.elastic.co/t/an-example-of-more-simple-pre-indexed-shapes-filtering-and-more-complex-ones-not-filtering/228183>\
**Category:** Elasticsearch\
**Tags:** maps\
**Created:** [April 15, 2020, 6:27pm UTC](https://discuss.elastic.co/t/an-example-of-more-simple-pre-indexed-shapes-filtering-and-more-complex-ones-not-filtering/228183 "2020-04-15T18:27:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![corrigancd](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@corrigancd](https://discuss.elastic.co/u/corrigancd)\
**Post date:** [April 15, 2020, 6:27pm UTC](https://discuss.elastic.co/t/an-example-of-more-simple-pre-indexed-shapes-filtering-and-more-complex-ones-not-filtering/228183/1 "2020-04-15T18:27:08Z")

</div>

Hello,

Using Elasticsearch and Kibana v7.5.2, I have encountered something unexpected while using pre-indexed shape filtering. [I have it documented in a google doc](https://docs.google.com/document/d/1caXtUg-do_lRVu60EUbcBcgMsvFND_9WtPJEC51tENI/edit?usp=sharing) -

The doc is split into 2 sections and the information required to replicate and the results are outlined. Here is a summary of what is happening:

1. I create an index with a geo\_point field, add one document and filter based on a bool should filter, where each polygon is part of the MultiPolygon that makes up the external bounds of the USA. **All works well**

2. 

a. I create an index with a shape field (shape field that is new to ES v7.4)  
b. Add one document with a point within the external bounds of Ireland  
c. Index the external bounds of Ireland and use a pre-indexed shape filter, the response includes the point within Ireland as expected. **All works is well**.  
d. Add another document which has a point within the USA multipolygon  
e. Index the external bounds of USA multipolygon and use a pre-indexed shape filter, the response does NOT include the point within USA as expected **All does NOT work well**

Considering that the Ireland pre-indexed shape works (as per point 2) AND when the shapes that make up the external bounds of the USA are used to filter on a polygon by polygon basis (as per point 1), the complexity of the USA external bounds may be causing problems for pre-indexed shape filters?

Best Regards,  
Edwin

---

<div class="post-metadata">

**Author:** ![Ignacio\_Vera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ignacio_vera/32/36674_2.png) [@Ignacio\_Vera](https://discuss.elastic.co/u/Ignacio_Vera)\
**Post date:** [April 16, 2020, 7:15am UTC](https://discuss.elastic.co/t/an-example-of-more-simple-pre-indexed-shapes-filtering-and-more-complex-ones-not-filtering/228183/2 "2020-04-16T07:15:20Z")

</div>

Hi,

I cannot access you document, would it be possible you share your example, maybe using something like GIST?

---

<div class="post-metadata">

**Author:** ![corrigancd](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@corrigancd](https://discuss.elastic.co/u/corrigancd)\
**Post date:** [April 16, 2020, 10:10am UTC](https://discuss.elastic.co/t/an-example-of-more-simple-pre-indexed-shapes-filtering-and-more-complex-ones-not-filtering/228183/3 "2020-04-16T10:10:20Z")

</div>

Hello Ignacio,

Thanks for quick reply, [gist is here](https://gist.github.com/corrigancd/1f892b1ff4a7ba154bc845eb707eb96d)

Edwin

---

<div class="post-metadata">

**Author:** ![corrigancd](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@corrigancd](https://discuss.elastic.co/u/corrigancd)\
**Post date:** [April 16, 2020, 10:34am UTC](https://discuss.elastic.co/t/an-example-of-more-simple-pre-indexed-shapes-filtering-and-more-complex-ones-not-filtering/228183/4 "2020-04-16T10:34:54Z")

</div>

Investigating this a bit further, I find the expected result when using the [geo\_shape pre-indexed filter type:](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/query-dsl-geo-shape-query.html)

```
POST companywithgeoshape/_doc/insideus
{
  "location": {
"type": "point",
"coordinates": [-100.0, 40.0]
  }
}

```

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/0/f0f251b38edf569a84792d0b382a4bf878d01e86.png)

---

<div class="post-metadata">

**Author:** ![Ignacio\_Vera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ignacio_vera/32/36674_2.png) [@Ignacio\_Vera](https://discuss.elastic.co/u/Ignacio_Vera)\
**Post date:** [April 16, 2020, 11:12am UTC](https://discuss.elastic.co/t/an-example-of-more-simple-pre-indexed-shapes-filtering-and-more-complex-ones-not-filtering/228183/5 "2020-04-16T11:12:11Z")

</div>

I had a look into you example and it seems the shape you are indexing in not USA but Canada, therefore the point is not inside:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/d/2db4522d4277978746b4f6cf640df986b87a3617.jpeg)

---

<div class="post-metadata">

**Author:** ![corrigancd](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@corrigancd](https://discuss.elastic.co/u/corrigancd)\
**Post date:** [April 16, 2020, 11:22am UTC](https://discuss.elastic.co/t/an-example-of-more-simple-pre-indexed-shapes-filtering-and-more-complex-ones-not-filtering/228183/6 "2020-04-16T11:22:54Z")

</div>

Oh wow, my bad.

Thanks for quick reply Ignacio 😊

---

<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:** [May 14, 2020, 11:23am UTC](https://discuss.elastic.co/t/an-example-of-more-simple-pre-indexed-shapes-filtering-and-more-complex-ones-not-filtering/228183/7 "2020-05-14T11:23:00Z")

</div>

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