# How to build a span near query with nested objects?

**URL:** <https://discuss.elastic.co/t/how-to-build-a-span-near-query-with-nested-objects/31883>\
**Category:** Elasticsearch\
**Created:** [October 8, 2015, 9:08pm UTC](https://discuss.elastic.co/t/how-to-build-a-span-near-query-with-nested-objects/31883 "2015-10-08T21:08:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manuel\_Islas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/manuel_islas/32/5177_2.png) [@Manuel\_Islas](https://discuss.elastic.co/u/Manuel_Islas)\
**Post date:** [October 8, 2015, 9:08pm UTC](https://discuss.elastic.co/t/how-to-build-a-span-near-query-with-nested-objects/31883/1 "2015-10-08T21:08:14Z")

</div>

I have a document like:

Document: {  
documentId,  
name,  
content,  
SubDocuments:[{  
name,  
displayName,  
content  
}]  
}

and want to run a span\_near query over the nested SubDocument properties. Any idea how to achieve this?

Thanks,

---

<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 5, 2017, 11:45pm UTC](https://discuss.elastic.co/t/how-to-build-a-span-near-query-with-nested-objects/31883/2 "2017-07-05T23:45:46Z")

</div>


