You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This improves the documentation and test coverage for the conversions
between numeric types (including numberic format strings, and the
`auto` target type) in the `convert` ingest processor.
Relates #133153
Copy file name to clipboardExpand all lines: docs/reference/enrich-processor/convert-processor.md
+34-2Lines changed: 34 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,16 +6,48 @@ mapped_pages:
6
6
7
7
# Convert processor [convert-processor]
8
8
9
-
10
9
Converts a field in the currently ingested document to a different type, such as converting a string to an integer. If the field value is an array, all members will be converted.
11
10
12
11
The supported types include: `integer`, `long`, `float`, `double`, `string`, `boolean`, `ip`, and `auto`.
13
12
13
+
Specifying a target `type` of `integer` supports inputs which are `Integer` values, `Long` values in 32-bit signed
14
+
integer range, or `String` values representing an integer in 32-bit signed integer range in either decimal format
15
+
(without a decimal point) or hex format (e.g. `"123"` or `"0x7b"`).
16
+
17
+
Specifying `long` supports inputs which are `Integer` values, `Long` values, or `String` values representing an integer
18
+
in 64-bit signed integer range in either decimal format (without a decimal point) or hex format (e.g. `"123"` or
19
+
`"0x7b"`).
20
+
21
+
Specifying `float` supports inputs which are `Integer` values, `Long` values (conversions from either `Integer` or
22
+
`Long` may lose precision for absolute values greater than 2^24), `Float` values, `Double` values (may lose precision),
23
+
`String` values representing a floating point number in decimal, scientific, or hex format (e.g. `"123.0"`, `"123.45"`,
24
+
`"1.23e2"`, or `"0x1.ecp6"`) or an integer (conversions from `String` may lose precision, and will give positive or
25
+
negative infinity if out of range for a 32-bit floating point value).
26
+
27
+
Specifying `double` supports inputs which are `Integer` values, `Long` values (may lose precision for absolute values
28
+
greater than 2^53), `Float` values, `Double` values, `String` values representing a floating point number in decimal,
29
+
scientific, or hex format (e.g. `"123.0"`, `"123.45"`, `"1.23e2"`, or `"0x1.ecp6"`) or an integer (conversions from
30
+
`String` may lose precision, and will give positive or negative infinity if out of range for a 64-bit floating point
31
+
value).
32
+
14
33
Specifying `boolean` will set the field to true if its string value is equal to `true` (ignore case), to false if its string value is equal to `false` (ignore case), or it will throw an exception otherwise.
15
34
16
35
Specifying `ip` will set the target field to the value of `field` if it contains a valid IPv4 or IPv6 address that can be indexed into an [IP field type](/reference/elasticsearch/mapping-reference/ip.md).
17
36
18
-
Specifying `auto` will attempt to convert the string-valued `field` into the closest non-string, non-IP type. For example, a field whose value is `"true"` will be converted to its respective boolean type: `true`. Do note that float takes precedence of double in `auto`. A value of `"242.15"` will "automatically" be converted to `242.15` of type `float`. If a provided field cannot be appropriately converted, the processor will still process successfully and leave the field value as-is. In such a case, `target_field` will be updated with the unconverted field value.
37
+
Specifying `auto` will attempt to convert a string-valued `field` into the closest non-string, non-IP type. For example,
38
+
a field whose value is `"true"` will be converted to its respective boolean type: `true`. A string representing an
39
+
integer in decimal or hex format (e.g. `"123"` or `"0x7b"`) will be converted to an `Integer` if the number fits in a
40
+
32-bit signed integer, else to a `Long` if it fits in a 64-bit signed integer, else to a `Float` (in which case it may
41
+
lose precision, and will give positive or negative infinity if out of range for a 32-bit floating point value). A string
42
+
representing a floating point number in decimal, scientific, or hex format (e.g. `"123.0"`, `"123.45"`, `"1.23e2"`, or
43
+
`"0x1.ecp6"`) will be converted to a `Float` (and may lose precision, and will give positive or negative infinity if out
44
+
of range for a 32-bit floating point value). If a provided field is either not a `String` or a `String` which cannot be
45
+
converted, the processor will still process successfully and leave the field value as-is. In such a case, `target_field`
46
+
will be updated with the unconverted field value.
47
+
48
+
N.B. If conversions other than those provided by this processor are required, the
49
+
[`script`](/reference/enrich-processor/script-processor.md) processor mey be used to implement the desired behaviour.
50
+
(The performance of the `script` processor should be as good or better than the `convert` processor.)
0 commit comments