Hey Guys,

Seems like there is an issue with a combined bool filter with nested docs.

I have the following mapping:

{
    "mappings": {
        "test": {
            "properties": {
                "name": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "attributes": {
                    "type": "nested",
                    "properties": {
                        "name": {
                            "type": "string",
                            "index": "not_analyzed"
                        },
                        "stringValue": {
                            "type": "string",
                            "index": "not_analyzed"
                        },
                        "doubleValue": {
                            "type": "double"
                        }
                    }
                }
            }
        }
    }
}
And I index the following document in it: 

{
  "name": "John Stamos",
  "attributes": [
    {
      "name": "Name",
      "stringValue": "John"
    },
    {
      "name": "Age",
      "doubleValue": 34
    }
  ]
}
If I run the following query, I get the correct result, which is the indexed 
document:


{
    "query": {
        "filtered": {
            "filter": {
                "nested": {
                    "path": "attributes",
                    "filter": {
                        "bool": {
                            "must": [
                                {
                                    "bool": {
                                        "must": [
                                            {
                                                "term": {
                                                    "attributes.name": "Name"
                                                }
                                            },
                                            {
                                                "term": {
                                                    "attributes.stringValue": 
"John"
                                                }
                                            }
                                        ]
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        }
    }
}
The query also works correctly if I filter by "Age". But if I combine two bool 
filters ("Name" and "Age"), then I don't get any results.

{
    "query": {
        "filtered": {
            "filter": {
                "nested": {
                    "path": "attributes",
                    "filter": {
                        "bool": {
                            "must": [
                                {
                                    "bool": {
                                        "must": [
                                            {
                                                "term": {
                                                    "attributes.name": "Name"
                                                }
                                            },
                                            {
                                                "term": {
                                                    "attributes.stringValue": 
"John"
                                                }
                                            }
                                        ]
                                    }
                                },
                                {
                                    "bool": {
                                        "must": [
                                            {
                                                "term": {
                                                    "attributes.name": "Age"
                                                }
                                            },
                                            {
                                                "range": {
                                                    "attributes.doubleValue": {
                                                        "gt": 5
                                                    }
                                                }
                                            }
                                        ]
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        }
    }
}

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/5E52EB8D-3FB3-41F3-9583-7493255AEE66%40venarc.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to