# Get all/equal from nested documents in elastic search

**URL:** <https://discuss.elastic.co/t/get-all-equal-from-nested-documents-in-elastic-search/152355>\
**Category:** Elasticsearch\
**Created:** [October 13, 2018, 6:38pm UTC](https://discuss.elastic.co/t/get-all-equal-from-nested-documents-in-elastic-search/152355 "2018-10-13T18:38:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pandit\_Biradar](https://avatars.discourse-cdn.com/v4/letter/p/c57346/32.png) [@Pandit\_Biradar](https://discuss.elastic.co/u/Pandit_Biradar)\
**Post date:** [October 13, 2018, 6:38pm UTC](https://discuss.elastic.co/t/get-all-equal-from-nested-documents-in-elastic-search/152355/1 "2018-10-13T18:38:59Z")

</div>

Hello Team,  
Please help me on this issue ,  
I want to search all the nested documents which all are equals , my elastic search mapping look like this

```
{
      "attribute_search_index": {
        "mappings": {
          "attribute_search": {
            "dynamic": "true",
            "properties": {
              "attrId": {
                "type": "text"
              },
              "attrName": {
                "type": "text"
              },
              "attributeChildData": {
                "type": "nested",
                "properties": {
                  "attributeChildId": {
                    "type": "integer"
                  },
                  "attributeChildTxt": {
                    "type": "text"
                  },
                  "attributeChild_responsible": {
                    "type": "nested",
                    "properties": {
                      "responsible_id": {
                        "type": "integer"
                      },
                      "responsible_name": {
                        "type": "text"
                      }
                    }
                  },
                  "attrId": {
                    "type": "integer"
                  }
                }
              },
              "attributePrj": {
                "type": "nested",
                "properties": {
                  "attributePrj_Id": {
                    "type": "integer"
                  },
                  "attributePrj_name": {
                    "type": "keyword"
                  }
                }
              }
            }
          }
        }
      }
    }

```

This is my bool query

```
{
"query":{
  "bool" : {
    "must" : [
      {
        "nested" : {
          "query" : {
            "bool" : {
              "must" : [
                {
                  "match" : {
                    "attributePrj.name" : {
                      "attributePrj_name" : "PROJ 121",
                      "operator" : "OR",
                      "prefix_length" : 0,
                      "max_expansions" : 50,
                      "fuzzy_transpositions" : true,
                      "lenient" : false,
                      "zero_terms_query" : "NONE",
                      "auto_generate_synonyms_phrase_query" : true,
                      "boost" : 1.0
                    }
                  }
                }
              ],
              "adjust_pure_negative" : true,
              "boost" : 1.0
            }
          },
          "path" : "attributePrj",
          "ignore_unmapped" : false,
          "score_mode" : "avg",
          "boost" : 1.0
        }
      },
      {
        "nested" : {
          "query" : {
            "bool" : {
              "must" : [
                {
                  "match" : {
                    "attributeChildData.attributeChild_responsible.responsible_id" : {
                      "query" : "100",
                      "operator" : "OR",
                      "prefix_length" : 0,
                      "max_expansions" : 50,
                      "fuzzy_transpositions" : true,
                      "lenient" : false,
                      "zero_terms_query" : "NONE",
                      "auto_generate_synonyms_phrase_query" : true,
                      "boost" : 1.0
                    }
                  }
                }
              ],
              "adjust_pure_negative" : true,
              "boost" : 1.0
            }
          },
          "path" : "attributeChildData.attributeChild_responsible",
          "ignore_unmapped" : false,
          "score_mode" : "avg",
          "boost" : 1.0
        }
      }
    ],
    "adjust_pure_negative" : true,
    "boost" : 1.0
  }
}
}

```

This gives me if any of the nested attributeChild\_responsible.responsible\_id equal "100" , I am looking if all nested under that document must have 100 then only return the result

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 10, 2018, 6:38pm UTC](https://discuss.elastic.co/t/get-all-equal-from-nested-documents-in-elastic-search/152355/2 "2018-11-10T18:38:59Z")

</div>

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