# Exists query works even if field is not indexed?

**URL:** <https://discuss.elastic.co/t/exists-query-works-even-if-field-is-not-indexed/162849>\
**Category:** Elasticsearch\
**Created:** [January 3, 2019, 4:31pm UTC](https://discuss.elastic.co/t/exists-query-works-even-if-field-is-not-indexed/162849 "2019-01-03T16:31:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![baller](https://avatars.discourse-cdn.com/v4/letter/b/f05b48/32.png) [@baller](https://discuss.elastic.co/u/baller)\
**Post date:** [January 3, 2019, 4:31pm UTC](https://discuss.elastic.co/t/exists-query-works-even-if-field-is-not-indexed/162849/1 "2019-01-03T16:31:14Z")

</div>

I'm seeing some interesting behavior and didn't see anything in the docs about it so thought I'd ask here.

I have a field that has `index` set to `false` yet I am still able to do an `exists` query on field. My understanding was that fields that are not indexed are not searchable, but Elasticsearch 5 and 6 both return correct results for these queries. What gives? Are `exists` queries able to be fulfilled even if the fields are not indexed? Is the performance worse if they're not indexed since it has to do a scan of all the documents?

Thanks!

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [January 3, 2019, 11:27pm UTC](https://discuss.elastic.co/t/exists-query-works-even-if-field-is-not-indexed/162849/2 "2019-01-03T23:27:37Z")

</div>

Could you post a repro? I tried this and `exists` doesn't return me any results in 6.4.2 as expected.

```auto
DELETE test
PUT test
{
  "mappings": {
    "_doc": {
      "properties": {
        "foo": {
          "type": "text",
          "index": false
        }
      }
    }
  }
}

PUT test/_doc/1
{
  "foo": "bar"
}

PUT test/_doc/2
{
  
}

POST test/_search
{
  "query": {
    "exists": {
      "field": "foo"
    }
  }
}

```

---

<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:** [January 31, 2019, 11:27pm UTC](https://discuss.elastic.co/t/exists-query-works-even-if-field-is-not-indexed/162849/3 "2019-01-31T23:27:50Z")

</div>

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