Ingest Pipeline - Check if a field exists

Hello,

I'm trying to do something that seems like it should be relatively simple, but I haven't been able to track down the correct syntax the documentation. I have a basic ingest pipeline which I want to use to reference other pipelines depending on whether a specific field exists in a given document. Basically something like this:

    { 
    "processors" : [
      {
        "pipeline" : {
          "name" : "generic_pipeline",
          "if": "[field1 does not exist]"
        }
      },
      {
        "pipeline": {
          "name": "specific_pipeline",
          "if": "[field1 does exist]"
        }
      }
    ]
    }

This wouldn't be a problem if I was just checking for the field's values, but I'm having trouble working out how to check if the field exists in the first place. Any assistance would be greatly appreciated.

@sean_wills
try "if" : "!(ctx.containsKey('field1'))" and "if" : "ctx.containsKey('field1')" respectively

2 Likes

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.