Exists query works even if field is not indexed?

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!

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

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"
    }
  }
}

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