# Default keyword analyzer not work

**URL:** <https://discuss.elastic.co/t/default-keyword-analyzer-not-work/293194>\
**Category:** Elasticsearch\
**Created:** [December 30, 2021, 10:06am UTC](https://discuss.elastic.co/t/default-keyword-analyzer-not-work/293194 "2021-12-30T10:06:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![5minutes](https://avatars.discourse-cdn.com/v4/letter/5/848f3c/32.png) [@5minutes](https://discuss.elastic.co/u/5minutes)\
**Post date:** [December 30, 2021, 10:06am UTC](https://discuss.elastic.co/t/default-keyword-analyzer-not-work/293194/1 "2021-12-30T10:06:23Z")

</div>

Hi,

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

Creating index:

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

```

Sending doc:

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

```

But still is indexed as both text and keyword:

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

```

thanks

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 30, 2021, 11:59am UTC](https://discuss.elastic.co/t/default-keyword-analyzer-not-work/293194/2 "2021-12-30T11:59:30Z")

</div>

You need to do something like this:

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

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 27, 2022, 12:00pm UTC](https://discuss.elastic.co/t/default-keyword-analyzer-not-work/293194/3 "2022-01-27T12:00:05Z")

</div>

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