Skip to content

Commit d304058

Browse files
authored
Update general-tips.md
1 parent 1313996 commit d304058

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

manage-data/ingest/transform-enrich/general-tips.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,14 @@ When you want to set the `user.name` field with a script:
7575

7676
- `ctx.user.name = ctx.user_name`
7777

78-
This works as long as `user_name` is populated. If it is null, you get null as value for user.name. Additionally, when the `user` object does not exist, it will error because Java needs you to define the `user` object first before adding a key `name` into it.
78+
This works as long as `user_name` is populated. If it is null you will get `null` as value. Additionally, when the `user` object does not exist, it will error because Java needs you to define the `user` object first before adding a key `name` into it. We cover the `new HashMap()` further down.
7979

8080
This is one of the alternatives to get it working when you only want to set it, if it is not null
8181

8282
```painless
8383
if (ctx.user_name != null) {
84-
ctx.user.name = ctx.user_name
84+
ctx.user = new HashMap();
85+
ctx.user.name = ctx.user_name;
8586
}
8687
```
8788

0 commit comments

Comments
 (0)