3
votes

What is better solution for storing just a text in elasticsearch 5.x for a text field no longer then 256 characters, when this field does NOT need to be:

  • searchable
  • indexed
  • analyzed
  • sortable...

Option 1) Set mapping to text with index=false

Option 2) Set mapping to keyword with index=false, doc_values=false

What is more space efficient? Or what is the difference between these two mappings whit these settings?

Thank you.

1
Go with 1st option, keyword is used for exact phrase matching.xeye

1 Answers

2
votes

I would definitely use the keyword type so your text is not analyzed (as if it was a text field).

In addition to the settings you mentioned, I'd set a few more parameters, such as the ignore_above and include_in_all.

So:

    "field_name": {
      "type":  "keyword",
      "index": false,
      "doc_values": false,
      "ignore_above": 256,
      "include_in_all": false
    }