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
Copy file name to clipboardExpand all lines: manage-data/ingest/transform-enrich/common-mistakes.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -150,7 +150,8 @@ Once you've checked `ctx.user?.geo?.region != null`, you can safely access `ctx.
150
150
151
151
#### **Do**: Use `.isEmpty()` for strings
152
152
153
-
To check if a string field is not empty, use the [`isEmpty()` method](elasticsearch://reference/scripting-languages/painless/painless#painless-api-reference-string) in your condition. For example:
153
+
% TO DO: Find link to `isEmpty()` method
154
+
To check if a string field is not empty, use the `isEmpty()` method in your condition. For example:
@@ -159,7 +160,7 @@ To check if a string field is not empty, use the [`isEmpty()` method](elasticsea
159
160
This ensures the field exists, is a string, and is not empty.
160
161
161
162
:::{tip}
162
-
For such checks you can also ommit the `instanceof String` and use an [`Elvis`](elasticsearch://reference/scripting-languages/painless/painless-operators-reference#elvis-operator) such as `if: ctx.user?.geo?.region?.isEmpty() ?: false`. This will only work when region is a String. If it is a double, object or any other type that does not have an `isEmpty()`function it will fail with a `Java Function not found` error.
163
+
For such checks you can also ommit the `instanceof String` and use an [`Elvis`](elasticsearch://reference/scripting-languages/painless/painless-operators-reference.md#elvis-operator) such as `if: ctx.user?.geo?.region?.isEmpty() ?: false`. This will only work when region is a String. If it is a double, object or any other type that does not have an `isEmpty()`function it will fail with a `Java Function not found` error.
Copy file name to clipboardExpand all lines: manage-data/ingest/transform-enrich/general-tips.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,7 +101,7 @@ You see that I switched up the null value to an empty String. Since the String h
101
101
102
102
One common thing I use it for is when dealing with numbers and casting. The field specifies the usage in `%`, however Elasticsearch doesn't like this, or better to say Kibana renders % as `0-1` for `0%-100%` and not `0-100`. `100` is equal to `10.000%`
103
103
104
-
- field: `cpu_usage = 100.00`
104
+
- field: `cpu_usage = 100.00`
105
105
-`ctx.cpu.usage = $('cpu_usage',0.0)/100`
106
106
107
107
This allows me to always set the `cpu.usage` field and not to worry about it, have an always working division. One other way to leverage this, in a simpler script is like this, but most scripts are rather complex so this is not that often applicable.
@@ -117,7 +117,7 @@ This allows me to always set the `cpu.usage` field and not to worry about it, ha
117
117
118
118
## Check if a value exists and is not null
119
119
120
-
In simplest case the `ignore_empty_value` parameter is available in most processors to handle fields without values. Or the `ignore_failure` parameter to let the processor fail without impacting the pipeline you but sometime you will need to use the [null safe operator `?.`](elasticsearch::/references/painless/current/painless-operators-reference.html#null-safe-operator) to check if a field exists and is not `null`.
120
+
In simplest case the `ignore_empty_value` parameter is available in most processors to handle fields without values. Or the `ignore_failure` parameter to let the processor fail without impacting the pipeline you but sometime you will need to use the [null safe operator `?.`](elasticsearch://reference/scripting-languages/painless/painless-operators-reference.md#null-safe-operator) to check if a field exists and is not `null`.
121
121
122
122
```json
123
123
POST _ingest/pipeline/_simulate
@@ -179,7 +179,7 @@ An [elvis](https://www.elastic.co/guide/en/elasticsearch/painless/current/painle
The reason for that is, if `event.category` is a number, object or anything other than a `String` then it does not have the `startsWith` function and therefore will error with function `startsWith` not available on type object.
@@ -306,7 +306,7 @@ POST _ingest/pipeline/_simulate
306
306
}
307
307
}
308
308
}
309
-
],
309
+
],
310
310
"pipeline": {
311
311
"processors": [
312
312
{
@@ -336,7 +336,7 @@ POST _ingest/pipeline/_simulate
0 commit comments