# ES|QL CIDR\_MATCH not working (or more likely I'm doing something wrong)?

**URL:** <https://discuss.elastic.co/t/es-ql-cidr-match-not-working-or-more-likely-im-doing-something-wrong/350035>\
**Category:** Elasticsearch\
**Created:** [December 27, 2023, 9:30pm UTC](https://discuss.elastic.co/t/es-ql-cidr-match-not-working-or-more-likely-im-doing-something-wrong/350035 "2023-12-27T21:30:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BenB196](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benb196/32/83401_2.png) [@BenB196](https://discuss.elastic.co/u/BenB196)\
**Post date:** [December 27, 2023, 9:30pm UTC](https://discuss.elastic.co/t/es-ql-cidr-match-not-working-or-more-likely-im-doing-something-wrong/350035/1 "2023-12-27T21:30:56Z")

</div>

Hi All,

I've been messing around with ES|QL a bit, but I'm having an issue with the [CIDR\_MATCH](https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-functions-operators.html#esql-cidr_match) function, I'm hoping someone can help with.

At a minimum, I have a document that looks like:

```json
{
  "host": {
    "name": "ip-10-0-0-1.example.com"
    "ip": [
      "10.0.0.1",
      "127.0.0.1"
    ]
  }
}

```

If I run the query:

```auto
FROM index
| WHERE host.name == "ip-10-0-0-1.example.com"

```

I get a response as expected.

But if I run the query

```auto
FROM index
| WHERE CIDR_MATCH(host.ip, "10.0.0.0/8")

```

I don't get any responses. Note that `host.ip` is mapped as an IP type here.

If I do something like:

```auto
FROM index
| EVAL ip = TO_STRING(host.ip)
| WHERE ip == "10.0.0.1"

```

I also don't get anything.

If I switch to the standard query DSL/KQL:

```json
...
"should": [
{
  "match_phrase": {
    "host.ip": "10.0.0.0/8"
  }
}
]
...

```

I get responses as expected.

Would anyone have any ideas on what could be the problem here?

I suspect it has to do with `host.ip`, being a multi-value field, but it's not very clear on how to proceed.

(Using 8.11.3 for entire stack)

Edit, I did find [this limitation](https://www.elastic.co/guide/en/elasticsearch/reference/current/esql-multivalued-fields.html#esql-multivalued-fields-functions) for mutlivalue fields and _functions_, but it doesn't mention operators which is what `CIDR_MATCH` is listed as.

---

<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 24, 2024, 9:31pm UTC](https://discuss.elastic.co/t/es-ql-cidr-match-not-working-or-more-likely-im-doing-something-wrong/350035/2 "2024-01-24T21:31:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ninoslavmiskovic](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ninoslavmiskovic/32/113140_2.png) [@ninoslavmiskovic](https://discuss.elastic.co/u/ninoslavmiskovic)\
**Post date:** [February 25, 2024, 8:05pm UTC](https://discuss.elastic.co/t/es-ql-cidr-match-not-working-or-more-likely-im-doing-something-wrong/350035/3 "2024-02-25T20:05:55Z")

</div>

Hej Ben,

You need to use MV\_EXPAND since it is a multi-value field.

Perhaps upgrade to 8.12 if possible.

So try:

from index  
| mv\_expand host\_ip  
| WHERE CIDR\_MATCH(host.ip, "10.0.0.0/8")  
| KEEP host.ip, @timestamp  
| limit 100
