ElasticSearch - Querying Embedded Nested Objects

44 views Asked by At

Trying to have a Nested docs in a parent element. So, I have a location property and inside that I have phoneNumbers "Nested" group of phoneNumbers. Trying to query this for documents that have multiple phone numbers.

Data Set

_source: {
  id: 123,
  location:{  //type: object
    phoneNumbers: [  //type:Nested
        {
           phone: 555-555-5555
           type: cell
        },
        {
           phone: 222-222-2222
           type: office
        },
        {
           phone: 333-333-3333
           type: fax
        }
    ]
  }
} 

I am trying write a query, where size of phoneNumber is greater than one. If I try to do it as a "Nested" document, I get an error about "location" not a nested object, if I try a script filter with _source.location.phoneNumbers.size()>0 I get "cannot invoke method size() on null object"

What am I missing?

0

There are 0 answers