I have a document that contains nested documents.  I know it is possible to 
combine multiple filters on fields in the root document, but I haven't 
figured out how to combine those filters with nested filters.

Take this query for example:


{
  "from": 0,
  "size": 20,
  "query": {
    "filtered": {
      "query": {
        "match_all": {}
      },
      "filter": {
        "bool": {
          "must": [
            {
              "term": {
                "company_id": 123
              }
            },
            {
              "nested": {
                "filter": {
                  "term": {
                    "categories.name": {
                      "value": "Engineering"
                    }
                  }
                },
                "path": "categories"
              }
            }
          ]
        }
      }
    }
  }
}


company_id is a field at the root of the document.  categories.name is a 
field at the root of a nested category document.  The following query 
returns 0 results, although there are documents that match this criteria. 
 Is it not possible to combine filters like this, or am I just doing it 
wrong?

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/39143c3b-f989-4f60-bce9-a59a3b857924%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to