# Nested object type and join:false and geo\_shape

**URL:** <https://discuss.elastic.co/t/nested-object-type-and-join-false-and-geo-shape/15705>\
**Category:** Elasticsearch\
**Created:** [February 10, 2014, 8:09pm UTC](https://discuss.elastic.co/t/nested-object-type-and-join-false-and-geo-shape/15705 "2014-02-10T20:09:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bants](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bants/32/1509_2.png) [@bants](https://discuss.elastic.co/u/bants)\
**Post date:** [February 10, 2014, 8:09pm UTC](https://discuss.elastic.co/t/nested-object-type-and-join-false-and-geo-shape/15705/1 "2014-02-10T20:09:48Z")

</div>

Hi All,

I would like to be able to search against documents using a geo\_shape  
filter where the geojson is a nested subdocument and only retrieve the 1  
sub document that matched the geographical filter (not the whole document).  
I think the docs (specifically nested object type and nested query/filter  
docs) state this is possible using join:false. For some reason I can't get  
it to work though and I'm convinced its a user error or lack of  
understanding.

On ES 90.5 and below is a worked example.

Can someone point me in the right direction please?

Thanks

# Clear the deck and create a new index

> curl -XDELETE [http://localhost:9200/test](http://localhost:9200/test)

{"ok":true,"acknowledged":true}

> curl -XPUT [http://localhost:9200/test](http://localhost:9200/test)

{"ok":true,"acknowledged":true}

# Set a new mapping for the testtype

> curl -XPUT [http://localhost:9200/test/testtype/\_mapping](http://localhost:9200/test/testtype/_mapping) -d '{"testtype":  
> {"properties": {"entities": {"type": "nested", "properties": {"geometry":  
> {"tree": "quadtree", "type": "geo\_shape","precision": "10m"}}}}}}'  
> {"ok":true,"acknowledged":true}

# Index a new document

curl -XPUT [http://localhost:9200/test/testtype/doc1](http://localhost:9200/test/testtype/doc1) -d '{"id" : "doc1",  
"entities": [{"geometry": {"type" : "Point", "coordinates": [0.0, 0.0]}},  
{"geometry": {"type" : "Point", "coordinates": [180.0, 90.0]}}]}'

# Query WITH join:false

> curl -XGET [http://localhost:9200/test/testtype/\_search](http://localhost:9200/test/testtype/_search) -d '{"query":  
> {"filtered": {"filter": {"nested" : {"path" : "entities", _"join":false_,  
> "filter" : {"geo\_shape": {"entities.geometry": {"shape": {"type":  
> "envelope","coordinates": [[-10.0, 10.0],[10.0, -10.0]]}}}}}},"query":  
> {"match\_all": {}}}}}'

{"took":0,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max\_score":null,"hits":}}

# Query WITHour join:false

> curl -XGET [http://localhost:9200/test/testtype/\_search](http://localhost:9200/test/testtype/_search) -d '{"query":  
> {"filtered": {"filter": {"nested" : {"path" : "entities", "filter" :  
> {"geo\_shape": {"entities.geometry": {"shape": {"type":  
> "envelope","coordinates": [[-10.0, 10.0],[10.0, -10.0]]}}}}}},"query":  
> {"match\_all": {}}}}}'

{"took":2,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max\_score":1.0,"hits":[{"\_index":"test","\_type":"testtype","\_id":"doc1","\_score":1.0,  
"\_source" : {"id" : "doc1", "entities": [{"geometry": {"type" : "Point",  
"coordinates": [0.0, 0.0]}}, {"geometry": {"type" : "Point", "coordinates":  
[180.0, 90.0]}}]}}]}}

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/87ea2d52-66e1-4418-917a-b9b8d720cb0a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/87ea2d52-66e1-4418-917a-b9b8d720cb0a%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![horse\_badorties\_ny](https://avatars.discourse-cdn.com/v4/letter/h/b9bd4f/32.png) [@horse\_badorties\_ny](https://discuss.elastic.co/u/horse_badorties_ny)\
**Post date:** [May 29, 2014, 1:16pm UTC](https://discuss.elastic.co/t/nested-object-type-and-join-false-and-geo-shape/15705/2 "2014-05-29T13:16:07Z")

</div>

Hello,

I am trying to achieve something very similar, where a nested filter is  
applied on a nested document and I only want the sub doc and not the root  
in the hit source. Setting the filter's 'join' to false always returns 0  
hits. Did you find a resolution?

Thank you!

On Monday, February 10, 2014 3:09:48 PM UTC-5, bants wrote:

> Hi All,
> 
> I would like to be able to search against documents using a geo\_shape  
> filter where the geojson is a nested subdocument and only retrieve the 1  
> sub document that matched the geographical filter (not the whole document).  
> I think the docs (specifically nested object type and nested query/filter  
> docs) state this is possible using join:false. For some reason I can't get  
> it to work though and I'm convinced its a user error or lack of  
> understanding.
> 
> On ES 90.5 and below is a worked example.
> 
> Can someone point me in the right direction please?
> 
> Thanks
> 
> # Clear the deck and create a new index
> 
> > curl -XDELETE [http://localhost:9200/test](http://localhost:9200/test)
> 
> {"ok":true,"acknowledged":true}
> 
> > curl -XPUT [http://localhost:9200/test](http://localhost:9200/test)
> 
> {"ok":true,"acknowledged":true}
> 
> # Set a new mapping for the testtype
> 
> > curl -XPUT [http://localhost:9200/test/testtype/\_mapping](http://localhost:9200/test/testtype/_mapping) -d '{"testtype":  
> > {"properties": {"entities": {"type": "nested", "properties": {"geometry":  
> > {"tree": "quadtree", "type": "geo\_shape","precision": "10m"}}}}}}'  
> > {"ok":true,"acknowledged":true}
> 
> # Index a new document
> 
> curl -XPUT [http://localhost:9200/test/testtype/doc1](http://localhost:9200/test/testtype/doc1) -d '{"id" : "doc1",  
> "entities": [{"geometry": {"type" : "Point", "coordinates": [0.0, 0.0]}},  
> {"geometry": {"type" : "Point", "coordinates": [180.0, 90.0]}}]}'
> 
> # Query WITH join:false
> 
> > curl -XGET [http://localhost:9200/test/testtype/\_search](http://localhost:9200/test/testtype/_search) -d '{"query":  
> > {"filtered": {"filter": {"nested" : {"path" : "entities", _"join":false_,  
> > "filter" : {"geo\_shape": {"entities.geometry": {"shape": {"type":  
> > "envelope","coordinates": [[-10.0, 10.0],[10.0, -10.0]]}}}}}},"query":  
> > {"match\_all": {}}}}}'
> 
> {"took":0,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max\_score":null,"hits":}}
> 
> # Query WITHour join:false
> 
> > curl -XGET [http://localhost:9200/test/testtype/\_search](http://localhost:9200/test/testtype/_search) -d '{"query":  
> > {"filtered": {"filter": {"nested" : {"path" : "entities", "filter" :  
> > {"geo\_shape": {"entities.geometry": {"shape": {"type":  
> > "envelope","coordinates": [[-10.0, 10.0],[10.0, -10.0]]}}}}}},"query":  
> > {"match\_all": {}}}}}'
> 
> {"took":2,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max\_score":1.0,"hits":[{"\_index":"test","\_type":"testtype","\_id":"doc1","\_score":1.0,  
> "\_source" : {"id" : "doc1", "entities": [{"geometry": {"type" : "Point",  
> "coordinates": [0.0, 0.0]}}, {"geometry": {"type" : "Point", "coordinates":  
> [180.0, 90.0]}}]}}]}}

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/3209ffa9-bf61-402e-a21a-571deaf34fad%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3209ffa9-bf61-402e-a21a-571deaf34fad%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![bants](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bants/32/1509_2.png) [@bants](https://discuss.elastic.co/u/bants)\
**Post date:** [June 8, 2014, 6:31pm UTC](https://discuss.elastic.co/t/nested-object-type-and-join-false-and-geo-shape/15705/3 "2014-06-08T18:31:06Z")

</div>

Hey - no, sorry I didn't ever get a response.

Picking up this work over the next couple of times so I'll see if I come up  
with anything.

On Thursday, May 29, 2014 2:16:07 PM UTC+1, [horse.bad...@gmail.com](mailto:horse.bad...@gmail.com) wrote:

> Hello,
> 
> I am trying to achieve something very similar, where a nested filter is  
> applied on a nested document and I only want the sub doc and not the root  
> in the hit source. Setting the filter's 'join' to false always returns 0  
> hits. Did you find a resolution?
> 
> Thank you!
> 
> On Monday, February 10, 2014 3:09:48 PM UTC-5, bants wrote:
> 
> > Hi All,
> > 
> > I would like to be able to search against documents using a geo\_shape  
> > filter where the geojson is a nested subdocument and only retrieve the 1  
> > sub document that matched the geographical filter (not the whole document).  
> > I think the docs (specifically nested object type and nested query/filter  
> > docs) state this is possible using join:false. For some reason I can't get  
> > it to work though and I'm convinced its a user error or lack of  
> > understanding.
> > 
> > On ES 90.5 and below is a worked example.
> > 
> > Can someone point me in the right direction please?
> > 
> > Thanks
> > 
> > # Clear the deck and create a new index
> > 
> > > curl -XDELETE [http://localhost:9200/test](http://localhost:9200/test)
> > 
> > {"ok":true,"acknowledged":true}
> > 
> > > curl -XPUT [http://localhost:9200/test](http://localhost:9200/test)
> > 
> > {"ok":true,"acknowledged":true}
> > 
> > # Set a new mapping for the testtype
> > 
> > > curl -XPUT [http://localhost:9200/test/testtype/\_mapping](http://localhost:9200/test/testtype/_mapping) -d '{"testtype":  
> > > {"properties": {"entities": {"type": "nested", "properties": {"geometry":  
> > > {"tree": "quadtree", "type": "geo\_shape","precision": "10m"}}}}}}'  
> > > {"ok":true,"acknowledged":true}
> > 
> > # Index a new document
> > 
> > curl -XPUT [http://localhost:9200/test/testtype/doc1](http://localhost:9200/test/testtype/doc1) -d '{"id" : "doc1",  
> > "entities": [{"geometry": {"type" : "Point", "coordinates": [0.0, 0.0]}},  
> > {"geometry": {"type" : "Point", "coordinates": [180.0, 90.0]}}]}'
> > 
> > # Query WITH join:false
> > 
> > > curl -XGET [http://localhost:9200/test/testtype/\_search](http://localhost:9200/test/testtype/_search) -d '{"query":  
> > > {"filtered": {"filter": {"nested" : {"path" : "entities", _"join":false_,  
> > > "filter" : {"geo\_shape": {"entities.geometry": {"shape": {"type":  
> > > "envelope","coordinates": [[-10.0, 10.0],[10.0, -10.0]]}}}}}},"query":  
> > > {"match\_all": {}}}}}'
> > 
> > {"took":0,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max\_score":null,"hits":}}
> > 
> > # Query WITHour join:false
> > 
> > > curl -XGET [http://localhost:9200/test/testtype/\_search](http://localhost:9200/test/testtype/_search) -d '{"query":  
> > > {"filtered": {"filter": {"nested" : {"path" : "entities", "filter" :  
> > > {"geo\_shape": {"entities.geometry": {"shape": {"type":  
> > > "envelope","coordinates": [[-10.0, 10.0],[10.0, -10.0]]}}}}}},"query":  
> > > {"match\_all": {}}}}}'
> > 
> > {"took":2,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max\_score":1.0,"hits":[{"\_index":"test","\_type":"testtype","\_id":"doc1","\_score":1.0,  
> > "\_source" : {"id" : "doc1", "entities": [{"geometry": {"type" : "Point",  
> > "coordinates": [0.0, 0.0]}}, {"geometry": {"type" : "Point", "coordinates":  
> > [180.0, 90.0]}}]}}]}}

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1ab3c47b-32c8-4905-b524-09e9692c8327%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1ab3c47b-32c8-4905-b524-09e9692c8327%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:23am UTC](https://discuss.elastic.co/t/nested-object-type-and-join-false-and-geo-shape/15705/4 "2017-07-06T01:23:52Z")

</div>


