How to enable store on keyword subfield in elasticsearch in case of dynamic mapping

how to enable store on keyword subfield in elasticsearch in case of dynamic mapping

Yes, you could use a dynamic template for that. Dynamic templates allow you to change how fields get mapped dynamically. In your case, you could use that to enable store on all dynamically mapped keyword multifields:

PUT my_index
{
  "mappings": {
    "dynamic_templates": [
      {
        "strings": {
          "match_mapping_type": "string",
          "mapping": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256,
                "store": true
              }
            }
          }
        }
      }
    ]
  }
}

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