doc_values

By default, OpenSearch indexes most fields for search purposes. The doc_values parameter enables document-to-term lookups for operations such as sorting, aggregations, and scripting.

The doc_values parameter accepts the following options.

OptionDescription
trueEnables doc_values for the field. Default is true.
falseDisables doc_values for the field.

The doc_values parameter is not supported for use in text fields.


Example: Creating an index with doc_values enabled and disabled

The following example request creates an index with doc_values enabled for one field and disabled for another:

  1. PUT my-index-001
  2. {
  3. "mappings": {
  4. "properties": {
  5. "status_code": {
  6. "type": "keyword"
  7. },
  8. "session_id": {
  9. "type": "keyword",
  10. "doc_values": false
  11. }
  12. }
  13. }
  14. }

copy