# Exists query not working on some fields in my index (version 5.1.1)

**URL:** <https://discuss.elastic.co/t/exists-query-not-working-on-some-fields-in-my-index-version-5-1-1/82037>\
**Category:** Elasticsearch\
**Created:** [April 11, 2017, 6:39pm UTC](https://discuss.elastic.co/t/exists-query-not-working-on-some-fields-in-my-index-version-5-1-1/82037 "2017-04-11T18:39:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![scotttam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/scotttam/32/10080_2.png) [@scotttam](https://discuss.elastic.co/u/scotttam)\
**Post date:** [April 11, 2017, 6:39pm UTC](https://discuss.elastic.co/t/exists-query-not-working-on-some-fields-in-my-index-version-5-1-1/82037/1 "2017-04-11T18:39:00Z")

</div>

I have an index with ~122 million documents. Some of the fields don't seem to be working with the exists query. For example, I have a doc like the following (many other fields omitted for brevity):

```
curl -XGET 'http://myes.com/my_index/my_docs/1000022379001'
{"_index":"my_index","_type":"my_docs","_id":"1000022379001","_version":4,"found":true,"_source":{"account_id":"782847669001","projection":"something"}}

```

But when I search all docs where projection exists, I get 0 hits:

```
curl -XGET 'http://myes.com/my_index/my_docs/_search?pretty' -d '
> {
> "query": {
> "exists": { "field": "projection" }
> }
> }
> '
{
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 24,
    "successful" : 24,
    "failed" : 0
  },
  "hits" : {
    "total" : 0,
    "max_score" : null,
    "hits" : []
  }
}

```

The mapping for the projection field is:

```
"projection": {
  "type": "keyword",
  "doc_values": false
},

```

Any thoughts or ideas on why this isn't working? Am I missing something?

Thanks,

Scott

---

<div class="post-metadata">

**Author:** ![scotttam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/scotttam/32/10080_2.png) [@scotttam](https://discuss.elastic.co/u/scotttam)\
**Post date:** [April 12, 2017, 3:29pm UTC](https://discuss.elastic.co/t/exists-query-not-working-on-some-fields-in-my-index-version-5-1-1/82037/2 "2017-04-12T15:29:12Z")

</div>

My bad... I had messed up the json file that defined my mapping. Sorry for the noise!

---

<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:** [May 10, 2017, 3:36pm UTC](https://discuss.elastic.co/t/exists-query-not-working-on-some-fields-in-my-index-version-5-1-1/82037/3 "2017-05-10T15:36:21Z")

</div>

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