Search code examples
elasticsearchsearchluceneinformation-retrievalelasticsearch-5

Is it possible to filter on a non-indexed field with doc_values=true in Elasticsearch


In Elasticsearch 5.6 using the following mapping:

"category" => [
    "type"=>"keyword",
    "doc_values"=>true,
    "index"=>false
    "store"=>true
]

I was given advice that it was possible to write a query that filters on this field because of its doc_values setting, even though the index attribute was set to false, but it seems like doc_values fields are only useful for aggregations and sorting.

Is it possible to create a query which filters on this field?


Solution

  • An field that is not indexed is, by definition, not searchable. Elasticsearch won't put it in the inverted index (which is used for searching). If you try to run a search query, you will get an error like Cannot search on field [category] since it is not indexed.