Ignore_above does not work

I'm trying to use "ignore_above" for a "keyword" type field without success.

My mapping:

{
	"settings": {
		"index": {
			"number_of_shards": 1,
			"number_of_replicas": 1
		}
	},
	"mappings": {
		"properties": {
			"name": {
				"type": "text"
			},
			"age": {
				"type": "integer"
			},
			"role": {
				"type": "keyword",
				"ignore_above": 5
			},
			"post_date": {
				"type": "date"
			},
			"message": {
				"type": "text"
			}
		}
	}
}

Request for data insertion:

POST /example/_doc

{
	"name": "User Name",
	"post_date": "1990-07-02T14:12:12",
	"role": ["This is a test"],
	"message": "trying out Elasticsearch"
}

My output is returning the full value of "role" even using "ignore_above":

GET /example/_search/

{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 1,
      "relation": "eq"
    },
    "max_score": 1.0,
    "hits": [
      {
        "_index": "example",
        "_type": "_doc",
        "_id": "1",
        "_score": 1.0,
        "_source": {
          "name": "fabio janio",
          "post_date": "1990-07-02T14:12:12",
          "role": ["This is a test"],
          "message": "trying out Elasticsearch"
        }
      }
    ]
  }
}

Did you try to search using this field?

The documentation says:

Do not index any string longer than this value. Defaults to 2147483647 so that all values would be accepted. Please however note that default dynamic mapping rules create a sub keyword field that overrides this default by setting ignore_above: 256 .

It does not mean that it should reject your document or modify the _source field.

Thank you. Now I understand how it works.

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