ignore-above.asciidoc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. [[ignore-above]]
  2. === `ignore_above`
  3. Strings longer than the `ignore_above` setting will not be indexed or stored.
  4. [source,js]
  5. --------------------------------------------------
  6. PUT my_index
  7. {
  8. "mappings": {
  9. "my_type": {
  10. "properties": {
  11. "message": {
  12. "type": "keyword",
  13. "ignore_above": 20 <1>
  14. }
  15. }
  16. }
  17. }
  18. }
  19. PUT my_index/my_type/1 <2>
  20. {
  21. "message": "Syntax error"
  22. }
  23. PUT my_index/my_type/2 <3>
  24. {
  25. "message": "Syntax error with some long stacktrace"
  26. }
  27. GET _search <4>
  28. {
  29. "aggs": {
  30. "messages": {
  31. "terms": {
  32. "field": "message"
  33. }
  34. }
  35. }
  36. }
  37. --------------------------------------------------
  38. // CONSOLE
  39. <1> This field will ignore any string longer than 20 characters.
  40. <2> This document is indexed successfully.
  41. <3> This document will be indexed, but without indexing the `message` field.
  42. <4> Search returns both documents, but only the first is present in the terms aggregation.
  43. TIP: The `ignore_above` setting is allowed to have different settings for
  44. fields of the same name in the same index. Its value can be updated on
  45. existing fields using the <<indices-put-mapping,PUT mapping API>>.
  46. This option is also useful for protecting against Lucene's term byte-length
  47. limit of `32766`.
  48. NOTE: The value for `ignore_above` is the _character count_, but Lucene counts
  49. bytes. If you use UTF-8 text with many non-ASCII characters, you may want to
  50. set the limit to `32766 / 4 = 8191` since UTF-8 characters may occupy at most
  51. 4 bytes.