# KQL filter if more values

**URL:** <https://discuss.elastic.co/t/kql-filter-if-more-values/254961>\
**Category:** Kibana\
**Created:** [November 10, 2020, 6:13pm UTC](https://discuss.elastic.co/t/kql-filter-if-more-values/254961 "2020-11-10T18:13:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![probson](https://avatars.discourse-cdn.com/v4/letter/p/e47c2d/32.png) [@probson](https://discuss.elastic.co/u/probson)\
**Post date:** [November 10, 2020, 6:13pm UTC](https://discuss.elastic.co/t/kql-filter-if-more-values/254961/1 "2020-11-10T18:13:49Z")

</div>

Hi,

Looking to query a field such as process.args:"atbroker.exe"  
but would only want a hit if there is more in process.args than just atbroker.exe

Is this possible?

Thanks  
Phil

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [November 10, 2020, 7:01pm UTC](https://discuss.elastic.co/t/kql-filter-if-more-values/254961/2 "2020-11-10T19:01:56Z")

</div>

What type data is this?

Try `process.args: *atbroker.exe*` to see if it works. But it depends on your data mapping and structure.

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [November 10, 2020, 7:54pm UTC](https://discuss.elastic.co/t/kql-filter-if-more-values/254961/3 "2020-11-10T19:54:18Z")

</div>

Assuming that `process.args` is an array of strings, then KQL cannot support this query. You can write this using the [script query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-script-query.html) with painless. Something like this would be your script:

```auto
doc['args'].size() > 0 && (
  !doc['args'].contains('/path/to/executable') ||
  (
    doc['args'].size() > 1 && doc['args'].contains('/path/to/executable')
  )
)

```

You can use this as an AND in the query DSL from Kibana.

---

<div class="post-metadata">

**Author:** ![probson](https://avatars.discourse-cdn.com/v4/letter/p/e47c2d/32.png) [@probson](https://discuss.elastic.co/u/probson)\
**Post date:** [November 11, 2020, 12:12pm UTC](https://discuss.elastic.co/t/kql-filter-if-more-values/254961/4 "2020-11-11T12:12:50Z")

</div>

Hi,

Thanks for the help, it sparked an idea which lead to the below.

I have gotten around the issue by using ruby in logstash to count the arrays, i noticed that since ECS 1.3 process.args\_count looks to be for what i need, as of winlogbeat 7.9.2 it is not implemented yet.

```auto
"event.set('[process][args_count]', event.get('[process][args]').length)"

```

Thanks  
Phil

---

<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:** [December 9, 2020, 12:12pm UTC](https://discuss.elastic.co/t/kql-filter-if-more-values/254961/5 "2020-12-09T12:12:51Z")

</div>

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