You want less than all the member of the elements in the array. Oh how
much, I'd like that too.
My understanding is that nested objects can prevent "cross object"
matches (searching for +name:"blue" +count:6 and incorrectly getting a
match), but when you match the parent document with a nested query you
can only get back either
(1) the whole parent (outer) document, or
(2) certain stored fields of the parent
that is all.
I believe at this time, the only thing you can do is ask for documents
that have at least 1 nested or 1 child document that matches.
If you switch to children docs you could:
(1) search for parent documents
(2) search for children documents that match your query of children, but
have the right parents.
Then combine the results.
If the criteria for matching children is not for scoring the relevancy
of the parent, you can put the matching of children in a filter and make
sure that result is cached, so even though you are going back again and
repeating the same possibly complex filter, the filtered children is
already done and it need only be further filtered by the requested
parent IDs.
Because of filter caching two requests can be very fast.
-Paul
On 12/13/2012 7:17 PM, Xiaowen Huang wrote:
> The query result is:
> {"took":0,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":1.724915,"hits":[{"_index":"test","_type":"es","_id":"GrmFSJo-RSetmjevjloA-Q","_score":1.724915,
> "_source" :
> {
> "obj1":[
> {
> "name":"blue",
> "count":4
> }
> ,{
> "name":"green",
> "count":6
> }
> ]
> }}]}}
>
> But only element {"name":"blue","count":4} in "obj1" matches the
> query. Can ES return result like this:
> {
> "obj1":[
> {
> "name":"blue",
> "count":4
> }
> ]
> }
> ?
>
> Thanks a lot.
>
--