convert.asciidoc 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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`, 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 `auto` will attempt to convert the string-valued `field` into the closest non-string type.
  12. For example, a field whose value is `"true"` will be converted to its respective boolean type: `true`. Do note
  13. that float takes precedence of double in `auto`. A value of `"242.15"` will "automatically" be converted to
  14. `242.15` of type `float`. If a provided field cannot be appropriately converted, the Convert Processor will
  15. still process successfully and leave the field value as-is. In such a case, `target_field` will
  16. still be updated with the unconverted field value.
  17. [[convert-options]]
  18. .Convert Options
  19. [options="header"]
  20. |======
  21. | Name | Required | Default | Description
  22. | `field` | yes | - | The field whose value is to be converted
  23. | `target_field` | no | `field` | The field to assign the converted value to, by default `field` is updated in-place
  24. | `type` | yes | - | The type to convert the existing value to
  25. | `ignore_missing` | no | `false` | If `true` and `field` does not exist or is `null`, the processor quietly exits without modifying the document
  26. include::common-options.asciidoc[]
  27. |======
  28. [source,js]
  29. --------------------------------------------------
  30. PUT _ingest/pipeline/my-pipeline-id
  31. {
  32. "description": "converts the content of the id field to an integer",
  33. "processors" : [
  34. {
  35. "convert" : {
  36. "field" : "id",
  37. "type": "integer"
  38. }
  39. }
  40. ]
  41. }
  42. --------------------------------------------------
  43. // NOTCONSOLE