Skip to content

Add support for the field API $('field name', 'fallback if null') in ingest context #101274

@philippkahr

Description

@philippkahr

Description

Hi,

I would to be able to use the field API like in runtime fields $('field name', 'fallback') in an ingest context.

This would allow me to write the following:

set:
   if: $('field', false)

Instead of writing this

set:
   if: ctx.field != null

I should also be able to do this, e.g. run the contains operator on a String.

if: $('field', '').contains('abc')

And this should also be covered:

if: ['abc','def'].contains($('field',''))

Only thing when doing this: if: $('field', false) it might happen that the field is a number, string and not boolean. Can we do the same as possible in other programming languages, where it just acts as truthy /falsy As soon as there is a value that is not false, it is automatically true?

So this example:

doc:
 { "_source": { "user": "philipp" }}
set:
  field: demo
  value: cool
  if: $('user', false)

then yields:

{
   "user": "philipp",
   "demo": "cool"
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions