Where's the docs for us "mere mortals"?

Hello,

First time poster. Please don't bite my head off, or tell me to Let Me Google That For You! I've genuinely struggled finding a good source of documentation for ingest pipeline syntax that's actually helpful to me. And I do heavily use the elastic.co site, but they sure could use a lot more example code for some different use cases.

Where can I find, under one roof, the operators such as these?

myfield.contains
myfield.length
myfield.startsWith
myfield.splitOnToken

Thank you very much in advance!

Hi @flatlander

There is this doc that talks a little about splitOntoken: Ingest processor context | Painless Scripting Language [8.13] | Elastic

I would use scripts in your scenario (I'm not sure if there is a processor for each of the options you mentioned), as below:

POST /_ingest/pipeline/_simulate
{
  "pipeline" :
  {
    "description": "use contains",
    "processors": [
      {
        "script": {
          "lang": "painless",
          "source": """
          if(ctx.foo.contains('bar')) {
            ctx.exists = true;
          }
          """
        }
      },
      {
        "script": {
          "lang": "painless",
          "source": """
            ctx.foo_length = ctx.foo.length();
          """
        }
      },
      {
        "script": {
          "lang": "painless",
          "source": """
            ctx.starts_with = ctx.foo.startsWith("bar");
          """
        }
      },
      {
        "script": {
          "lang": "painless",
          "source": """
            def arr = ctx.foo.splitOnToken("-");
            ctx.new_field_foo = arr[0];
            ctx.new_field_bar = arr[1];
          """
        }
      }
    ]
  },
  "docs": [
    {
      "_index": "index",
      "_id": "id",
      "_source": {
        "foo": "bar-foo"
      }
    }
  ]
}
1 Like