# Searching fields inside nested object arrays

**URL:** <https://discuss.elastic.co/t/searching-fields-inside-nested-object-arrays/12996>\
**Category:** Elasticsearch\
**Created:** [July 30, 2013, 2:07am UTC](https://discuss.elastic.co/t/searching-fields-inside-nested-object-arrays/12996 "2013-07-30T02:07:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdyck](https://avatars.discourse-cdn.com/v4/letter/j/47e85d/32.png) [@jdyck](https://discuss.elastic.co/u/jdyck)\
**Post date:** [July 30, 2013, 2:07am UTC](https://discuss.elastic.co/t/searching-fields-inside-nested-object-arrays/12996/1 "2013-07-30T02:07:38Z")

</div>

Hey all,

I'm fairly new to ES and am using it for a new project of mine. Starting off, I have a simple mapping for a customer, which has a first and last name, and a list of payment information objects. If I were doing this in SQL, it would be something like a customer table, and a payment info table with a 1:many relationship.

Here's a simple example of what I'm trying to do: [https://gist.github.com/anonymous/6109593](https://gist.github.com/anonymous/6109593)

I'm hoping to find any customer based on any match in the nested array of paymentInfos, i.e. finding any users who've had a paymentInfo with billingZip 10101. This query returns no results, and I'm not sure why. Can anyone point me in the right direction as to why this query doesn't work, and if there are any changes I can make to either my query or mapping to have it return the user properly?

Thanks!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 30, 2013, 2:10pm UTC](https://discuss.elastic.co/t/searching-fields-inside-nested-object-arrays/12996/2 "2013-07-30T14:10:46Z")

</div>

First comment: thanks for the gist. It really helps to help you!

I rewrote things here: [gist:6113034 · GitHub](https://gist.github.com/dadoonet/6113034)

Some notes (only to be applied on curl recreation scripts):  
Wait for yellow when you create an index  
Add a refresh after indexing a document  
When searching in nested, use nested filters.

Hope this helps

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 30 juil. 2013 à 04:07, jdyck [jeff.c.dyck@gmail.com](mailto:jeff.c.dyck@gmail.com) a écrit :

> Hey all,
> 
> I'm fairly new to ES and am using it for a new project of mine. Starting  
> off, I have a simple mapping for a customer, which has a first and last  
> name, and a list of payment information objects. If I were doing this in  
> SQL, it would be something like a customer table, and a payment info table  
> with a 1:many relationship.
> 
> Here's a simple example of what I'm trying to do:  
> [gist:6109593 · GitHub](https://gist.github.com/anonymous/6109593)
> 
> I'm hoping to find any customer based on any match in the nested array of  
> paymentInfos, i.e. finding any users who've had a paymentInfo with  
> billingZip 10101. This query returns no results, and I'm not sure why. Can  
> anyone point me in the right direction as to why this query doesn't work,  
> and if there are any changes I can make to either my query or mapping to  
> have it return the user properly?
> 
> Thanks!
> 
> --  
> View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/Searching-fields-inside-nested-object-arrays-tp4038848.html](http://elasticsearch-users.115913.n3.nabble.com/Searching-fields-inside-nested-object-arrays-tp4038848.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:23am UTC](https://discuss.elastic.co/t/searching-fields-inside-nested-object-arrays/12996/3 "2017-07-06T02:23:48Z")

</div>

Closed on July 6, 2017, 2:23am UTC


