convert.asciidoc 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. [[convert-processor]]
  2. === Convert processor
  3. ++++
  4. <titleabbrev>Convert</titleabbrev>
  5. ++++
  6. Converts a field in the currently ingested document to a different type, such as converting a string to an integer.
  7. If the field value is an array, all members will be converted.
  8. The supported types include: `integer`, `long`, `float`, `double`, `string`, `boolean`, `ip`, and `auto`.
  9. Specifying `boolean` will set the field to true if its string value is equal to `true` (ignore case), to
  10. false if its string value is equal to `false` (ignore case), or it will throw an exception otherwise.
  11. Specifying `ip` will set the target field to the value of `field` if it contains a valid IPv4 or IPv6 address
  12. that can be indexed into an <<ip,IP field type>>.
  13. Specifying `auto` will attempt to convert the string-valued `field` into the closest non-string, non-IP type.
  14. For example, a field whose value is `"true"` will be converted to its respective boolean type: `true`. Do note
  15. that float takes precedence of double in `auto`. A value of `"242.15"` will "automatically" be converted to
  16. `242.15` of type `float`. If a provided field cannot be appropriately converted, the processor will
  17. still process successfully and leave the field value as-is. In such a case, `target_field` will
  18. be updated with the unconverted field value.
  19. [[convert-options]]
  20. .Convert Options
  21. [options="header"]
  22. |======
  23. | Name | Required | Default | Description
  24. | `field` | yes | - | The field whose value is to be converted
  25. | `target_field` | no | `field` | The field to assign the converted value to, by default `field` is updated in-place
  26. | `type` | yes | - | The type to convert the existing value to
  27. | `ignore_missing` | no | `false` | If `true` and `field` does not exist or is `null`, the processor quietly exits without modifying the document
  28. include::common-options.asciidoc[]
  29. |======
  30. [source,js]
  31. --------------------------------------------------
  32. PUT _ingest/pipeline/my-pipeline-id
  33. {
  34. "description": "converts the content of the id field to an integer",
  35. "processors" : [
  36. {
  37. "convert" : {
  38. "field" : "id",
  39. "type": "integer"
  40. }
  41. }
  42. ]
  43. }
  44. --------------------------------------------------
  45. // NOTCONSOLE