Default keyword analyzer not work

Hi,

I would like all my fields to be indexed as a keyword.

Creating index:

PUT abcd
{
  "settings": {
    "analysis": {
      "analyzer": {
        "default": {
          "type": "keyword"
        }
      }
    }
  }
}

Sending doc:

POST abcd/_doc
{
  "foo": "bar"
}

But still is indexed as both text and keyword:

{
  "abcd" : {
    "mappings" : {
      "properties" : {
        "foo" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        }
      }
    }
  }
}

thanks

You need to do something like this:

PUT abcd/
{
  "mappings": {
    "dynamic_templates": [
      {
        "strings_as_keyword": {
          "match_mapping_type": "string",
          "mapping": {
            "type": "keyword"
          }
        }
      }
    ]
  }
}

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