# Filter-code errors apparently cause the filter not to be applied and I get nothing in Elasticsearch

**URL:** <https://discuss.elastic.co/t/filter-code-errors-apparently-cause-the-filter-not-to-be-applied-and-i-get-nothing-in-elasticsearch/159262>\
**Category:** Logstash\
**Created:** [December 4, 2018, 12:50am UTC](https://discuss.elastic.co/t/filter-code-errors-apparently-cause-the-filter-not-to-be-applied-and-i-get-nothing-in-elasticsearch/159262 "2018-12-04T00:50:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![RussellBateman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/russellbateman/32/34928_2.png) [@RussellBateman](https://discuss.elastic.co/u/RussellBateman)\
**Post date:** [December 4, 2018, 12:50am UTC](https://discuss.elastic.co/t/filter-code-errors-apparently-cause-the-filter-not-to-be-applied-and-i-get-nothing-in-elasticsearch/159262/1 "2018-12-04T00:50:31Z")

</div>

I'm trying to enhance a working filter I wrote that does the first `dissect` with only attempting that from now on if field `source` contains _audit.log_ or using a different `dissect` if `source` contains _debug.log_. Then, if either succeeds, I'd like to remove the `message` field (that I will have parsed using `dissect`).

```
  if "audit.log" in [source]
  {
    dissect
    {
      mapping =>
      {
        "message" => ...
      }
    }
  }
  else if "debug.log" in [source]
  {
    dissect
    {
      mapping =>
      {
        "message" => ...
      }
    }
  }
  if "_dissectfailure" not in [tags]
  {
    remove_field => ["message"]
  }

```

(Yes, the ellipses cover real, working code.) As I say, when this code wasn't surrounded by the `if then else if` conditional, it worked.

---

<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:** [January 1, 2019, 12:50am UTC](https://discuss.elastic.co/t/filter-code-errors-apparently-cause-the-filter-not-to-be-applied-and-i-get-nothing-in-elasticsearch/159262/2 "2019-01-01T00:50:44Z")

</div>

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