多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# ignore_above(忽略超越限制的字段) 原文链接 : [https://www.elastic.co/guide/en/elasticsearch/reference/5.3/ignore-above.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/ignore-above.html) 译文链接 : [http://www.apache.wiki/pages/createpage-entervariables.action?templateId=4816898&spaceKey=Elasticsearch&title=&newSpaceKey=Elasticsearch&fromPageId=9405287](http://www.apache.wiki/pages/createpage-entervariables.action?templateId=4816898&spaceKey=Elasticsearch&title=&newSpaceKey=Elasticsearch&fromPageId=9405287) 贡献者 : @您的名字,[ApacheCN](/display/~apachecn),[Apache中文网](/display/~apachechina) 字符串长度超过 **ignore_above** 设置的不会被索引和存储. ``` curl -XPUT 'localhost:9200/my_index?pretty' -H 'Content-Type: application/json' -d' { "mappings": { "my_type": { "properties": { "message": { "type": "keyword", "ignore_above": 20 # 1 } } } } } ' curl -XPUT 'localhost:9200/my_index/my_type/1?pretty' -H 'Content-Type: application/json' -d' # 2 { "message": "Syntax error" } ' curl -XPUT 'localhost:9200/my_index/my_type/2?pretty' -H 'Content-Type: application/json' -d' # 3 { "message": "Syntax error with some long stacktrace" } ' curl -XGET 'localhost:9200/_search?pretty' -H 'Content-Type: application/json' -d' # 4 { "aggs": { "messages": { "terms": { "field": "message" } } } } ``` | 1 | 字段会忽略超过20个字符的字符串. | | 2 | 这个 **document** 成功被索引. | | 3 | 这个 **document** 会被索引,但是不会索引 **message** 字段. | | 4 | 搜索返回两个文档,但只有第一个存在于 **terms**(词条)聚合中. | tip **ignore_above** 设置允许在相同索引的相同名称的字段有不同的配置,可以使用 [PUT mapping API](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/indices-put-mapping.html "Put Mapping") 在现有字段上更新其值。 此选项对于防止Lucene term(词条)长度超过32766是有用的. **ignore_above **的值是字符数,但 **Lucene **计数的是字节。所以如果你使用具有许多非ASCII字符的UTF-8文本,则可能需要将限制设置为 **32766/3 = 10922**,因为UTF-8字符可能占用至多3个字节。