split.asciidoc 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. [[split-processor]]
  2. === Split processor
  3. ++++
  4. <titleabbrev>Split</titleabbrev>
  5. ++++
  6. Splits a field into an array using a separator character. Only works on string fields.
  7. [[split-options]]
  8. .Split Options
  9. [options="header"]
  10. |======
  11. | Name | Required | Default | Description
  12. | `field` | yes | - | The field to split
  13. | `separator` | yes | - | A regex which matches the separator, eg `,` or `\s+`
  14. | `target_field` | no | `field` | The field to assign the split value to, by default `field` is updated in-place
  15. | `ignore_missing` | no | `false` | If `true` and `field` does not exist, the processor quietly exits without modifying the document
  16. | `preserve_trailing`| no | `false` | Preserves empty trailing fields, if any.
  17. include::common-options.asciidoc[]
  18. |======
  19. [source,js]
  20. --------------------------------------------------
  21. {
  22. "split": {
  23. "field": "my_field",
  24. "separator": "\\s+" <1>
  25. }
  26. }
  27. --------------------------------------------------
  28. // NOTCONSOLE
  29. <1> Treat all consecutive whitespace characters as a single separator
  30. If the `preserve_trailing` option is enabled, any trailing empty fields in the input will be preserved. For example,
  31. in the configuration below, a value of `A,,B,,` in the `my_field` property will be split into an array of five elements
  32. `["A", "", "B", "", ""]` with two empty trailing fields. If the `preserve_trailing` property were not enabled, the two
  33. empty trailing fields would be discarded resulting in the three-element array `["A", "", "B"]`.
  34. [source,js]
  35. --------------------------------------------------
  36. {
  37. "split": {
  38. "field": "my_field",
  39. "separator": ",",
  40. "preserve_trailing": true
  41. }
  42. }
  43. --------------------------------------------------
  44. // NOTCONSOLE