# Nested/hierarchical Elasticsearch query syntax?

**URL:** <https://discuss.elastic.co/t/nested-hierarchical-elasticsearch-query-syntax/133362>\
**Category:** Elasticsearch\
**Created:** [May 25, 2018, 8:04pm UTC](https://discuss.elastic.co/t/nested-hierarchical-elasticsearch-query-syntax/133362 "2018-05-25T20:04:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlixfeld](https://avatars.discourse-cdn.com/v4/letter/j/9fc348/32.png) [@jlixfeld](https://discuss.elastic.co/u/jlixfeld)\
**Post date:** [May 25, 2018, 8:04pm UTC](https://discuss.elastic.co/t/nested-hierarchical-elasticsearch-query-syntax/133362/1 "2018-05-25T20:04:01Z")

</div>

Hey there,

I'm having a hard time wrapping my head around Elasticsearch search syntax in Kibana.

I have created this filter that works:

```
{
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "flow.src_addr": "10.0.0.0/24"
          }
        },
        {
          "match": {
            "flow.dst_addr": "10.0.0.0/24"
          }
        },
        {
          "match": {
            "flow.src_addr": "10.0.1.0/24"
          }
        },
        {
          "match": {
            "flow.dst_addr": "10.0.1.0/24"
          }
        }
      ]
    }
  }
}

```

What I'm trying to do is simplify that syntax to the Elasticsearch equivalent of something along the lines of:

`((flow.dst_addr OR flow.src_addr) AND (10.0.1.0/24 OR 10.0.3.0/24 OR 10.0.3.0/24 OR 10.13.18.0/24 OR ... etc))`

Is that possible?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 26, 2018, 5:30am UTC](https://discuss.elastic.co/t/nested-hierarchical-elasticsearch-query-syntax/133362/2 "2018-05-26T05:30:30Z")

</div>

Assuming you IP fields are mapped as type `ip`, you should be able to use a [term query](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/ip.html#_querying_literal_ip_literal_fields) to do what you are looking for.

---

<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:** [June 23, 2018, 5:30am UTC](https://discuss.elastic.co/t/nested-hierarchical-elasticsearch-query-syntax/133362/3 "2018-06-23T05:30:30Z")

</div>

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