Query based on array item

Hi,

My document looks like this

{  

"branchCode":"WA-0104556",
"items":[
{
"id":"CAR-0014",
"qty":4,
"category":"PRIMARY"
},
{
"id":"CAR-0015",
"qty":5,
"category":"PRIMARY"
},
{
"id":"CAR-0016",
"qty":4,
"category":"MISCELLANNEOUS"
}
]
}

how do I query for something like:

  1. Get me all documents whose NONE of its items' "category" is PRIMARY
  2. Get me all documents whose ANY of its items' "category" is MISCELLANEOUS

is there any special way when uploading the document to ES? what's the datatype and index type for the field "items"? The document structure shown above is structure in DB, not ES.
ES index is not yet created for this one.

thanks

Nothing special to do.

Just index it.

Then search with a bool query

Must not clause for the first case
Filter clause for the second one

dang, I forgot about the "must not" clause...
feel like an idiot here...
anyway, thanks a lot

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.