# Nested filter with zero results only for a specific attribute

**URL:** <https://discuss.elastic.co/t/nested-filter-with-zero-results-only-for-a-specific-attribute/23697>\
**Category:** Elasticsearch\
**Created:** [May 27, 2015, 1:40pm UTC](https://discuss.elastic.co/t/nested-filter-with-zero-results-only-for-a-specific-attribute/23697 "2015-05-27T13:40:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SpinBoldak](https://avatars.discourse-cdn.com/v4/letter/s/67e7ee/32.png) [@SpinBoldak](https://discuss.elastic.co/u/SpinBoldak)\
**Post date:** [May 27, 2015, 1:40pm UTC](https://discuss.elastic.co/t/nested-filter-with-zero-results-only-for-a-specific-attribute/23697/1 "2015-05-27T13:40:53Z")

</div>

Hi,

I'm trying to apply a nested filter on a document but, for when I filter  
specifically by one of the nested attributes, I always get 0 results. For  
example, with a mapping like:

```
"PARTNER": {
   "properties": {
        "Addresses": {
             "properties": {
                    "CountyCode": {
                             "type": "string"
                    },
                    "EntityCode": {
                        "type": "string"
                    }, [...]
               }
        }, "type": "nested"
     }, [...]
}

```

I'm able to perform a filter on the CountyCode attribute, but if I filter  
on the EntityCode, i always get zero results:

```
{
  "from": 0,
  "size": 10,
  "query": {
    "filtered": {
      "query": {
        "bool": {
          "must": {
            "match_all": {}
          }
        }
      },
      "filter": {
        "nested": {
          "filter": {
            "bool": {
              "must": {
                "query": {
                  "query_string": {
                    "query": "*",
                    "fields": [
                      "EntityCode"
                    ]
                  }
                }
              }
            }
          },
          "path": "Addresses"
        }
      }
    }
  }
}

```

That query gets zero results, if I replace the field with CountyCode, it  
gives me proper results.  
I'm performing the queries on the web-based console, on ES 1.4.2,.

The nested documents have the format:

```
{
    "CountyCode": "516",
    "EntityCode": "203",
    [...]
}

```

Any idea on why that one field returns nothing ?

Thanks!

## -- Please update your bookmarks! We have moved to [https://discuss.elastic.co/](https://discuss.elastic.co/)

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+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/62363661-ede8-4179-bf90-b20ed716c041%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/62363661-ede8-4179-bf90-b20ed716c041%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 12:11am UTC](https://discuss.elastic.co/t/nested-filter-with-zero-results-only-for-a-specific-attribute/23697/2 "2017-07-06T00:11:37Z")

</div>


