Fix Elasticsearch “No handler for type [keyword]”

Check the Elasticsearch version and mapping structure before correcting a keyword mapping error on an older cluster.

Best practices
Log monitoring illustration

When Elasticsearch reports No handler for type [keyword] declared on field, first check the server version. Elasticsearch 2.x and earlier do not recognize keyword; Elasticsearch 5 introduced it alongside text.

Run this request in a client connected to the affected cluster:

GET /

Read version.number in the response. Confirm the endpoint is the same one used by the failing application or shipper, especially when several environments share similar names.

Match the mapping to the server

Server version Exact-value string mapping
Elasticsearch 2.x and earlier "type": "string", "index": "not_analyzed"
Elasticsearch 5 and later "type": "keyword"

For an Elasticsearch 2.x maintenance task, a complete index-creation example includes the old mapping type wrapper:

PUT legacy-hosts
{
  "mappings": {
    "host": {
      "properties": {
        "hostname": { "type": "string", "index": "not_analyzed" }
      }
    }
  }
}

This is historical syntax, not a configuration to copy into a current cluster. On modern Elasticsearch, use a typeless mapping with hostname mapped as keyword.

Prefer a planned upgrade over a permanent workaround

Elasticsearch 2.x is obsolete. Follow a supported migration path, including client and index compatibility checks; a direct jump from an old major release is not automatically supported. Changing a template does not rewrite existing field types. Where the mapping needs to change, create the destination index correctly and reindex the data.

If a recent server produces a similar error for another type, check spelling, plugin requirements, and the exact request structure instead of assuming an old version is the cause.

Check the component installing the mapping

Filebeat and Logstash may install templates automatically. Their versions and templates must be compatible with the server. Disabling automatic template installation only prevents that installation attempt; it does not make an incompatible client or data model compatible.

For full-text search plus exact matching on modern releases, map a field as text with a keyword subfield. Elastic explains the string-type transition and the Elasticsearch 2.4 mapping structure.

Get a tailored plan

Contact us

Join the community

Scan with WeChat
to join the community

Try Guance

Start online and pay only for what you use.

Get started

Choose a Guance plan

Code hosting