# String comparison in if condition of pipeline doesn't match

**URL:** <https://discuss.elastic.co/t/string-comparison-in-if-condition-of-pipeline-doesnt-match/187849>\
**Category:** Elasticsearch\
**Created:** [June 27, 2019, 1:38pm UTC](https://discuss.elastic.co/t/string-comparison-in-if-condition-of-pipeline-doesnt-match/187849 "2019-06-27T13:38:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lobotomeh](https://avatars.discourse-cdn.com/v4/letter/l/96bed5/32.png) [@lobotomeh](https://discuss.elastic.co/u/lobotomeh)\
**Post date:** [June 27, 2019, 1:38pm UTC](https://discuss.elastic.co/t/string-comparison-in-if-condition-of-pipeline-doesnt-match/187849/1 "2019-06-27T13:38:19Z")

</div>

I'm trying to create a pipeline in Elasticsearch. I have to make a check before to know what pipeline to use, so I've made a pipeline that do the routing, like this :

```auto
{
  "description": "A pipeline of pipelines for log files",
  "version": 1,
  "processors": [
    {
      "pipeline": {
        "if": """ctx.applicative_code =~ /AFA[@]959[@]333-SERVICE[@]1.0.0.SIG/ """,
        "name": "ged_pipeline"
      }
    },
    {
      "fail": {
        "message": "This pipeline requires applicative_code to be one of: 'AFA@959@333-SERVICE@1.0.0.SIG'"
      }
    }
  ]
}

```

To test it, I use the \_simulate API :

```auto
POST _ingest/pipeline/logs_pipeline/_simulate
{
  "docs": [
    {
      "_source": {
        "message_log": "127.0.0.1:50613||Download||agent||S0000||PM000||Q||{5C7A4600-C422-4D81-BD02-39072E06F646}",
        "applicative_code": "AFA@959@333-SERVICE@1.0.0.SIG"
      }
    }
  ]
}

```

And the response is this :

```auto
 "error" : {
        "root_cause" : [
          {
            "type" : "exception",
            "reason" : "java.lang.IllegalArgumentException: org.elasticsearch.ingest.common.FailProcessorException: This pipeline requires applicative_code to be one of: 'AFA@959@333-SERVICE@1.0.0.SIG'",
            "header" : {
              "processor_type" : "fail"
            }
          }
        ],
        "type" : "exception",
        "reason" : "java.lang.IllegalArgumentException: org.elasticsearch.ingest.common.FailProcessorException: This pipeline requires applicative_code to be one of: 'AFA@959@333-SERVICE@1.0.0.SIG'",
        "caused_by" : {
          "type" : "illegal_argument_exception",
          "reason" : "org.elasticsearch.ingest.common.FailProcessorException: This pipeline requires applicative_code to be one of: 'AFA@959@333-SERVICE@1.0.0.SIG'",
          "caused_by" : {
            "type" : "fail_processor_exception",
            "reason" : "This pipeline requires applicative_code to be one of: 'AFA@959@333-SERVICE@1.0.0.SIG'"
          }

```

So, it seems that my condition doesn't match. The reason why i'm using a regex here is that the special character "@" mess up the string comparison. What i've tried so far, in the if condition of the pipeline :

```auto
"if": """ctx.applicative_code == "AFA@959@333-SERVICE@1.0.0.SIG" """

```

Result : doesn't work, the @ is interpreted and I can't escape it using \

```auto
"if": """ctx.applicative_code.compareTo("AFA@959@333-SERVICE@1.0.0.SIG") """

```

Result : Same thing, the @ is interpreted

Any idea ?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 25, 2019, 1:38pm UTC](https://discuss.elastic.co/t/string-comparison-in-if-condition-of-pipeline-doesnt-match/187849/2 "2019-07-25T13:38:23Z")

</div>

Closed on July 25, 2019, 1:38pm UTC

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