# Access to filter values in script kibana

**URL:** https://discuss.elastic.co/t/access-to-filter-values-in-script-kibana/273753
**Category:** Kibana
**Created:** [May 23, 2021, 7:19am UTC](https://discuss.elastic.co/t/access-to-filter-values-in-script-kibana/273753 "2021-05-23T07:19:29Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![AR\_2021](https://avatars.discourse-cdn.com/v4/letter/a/e8c25b/32.png) [@AR\_2021](https://discuss.elastic.co/u/AR_2021)
#### Post date: [May 23, 2021, 7:19am UTC](https://discuss.elastic.co/t/access-to-filter-values-in-script-kibana/273753/1 "2021-05-23T07:19:29Z")

</div>

In kibana want to use filter bar value in my script (Advance section). Is there a way or a function to access the filter value in script? or any solution ?

---

<div class="post-metadata">

### Author: ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)
#### Post date: [May 26, 2021, 7:45pm UTC](https://discuss.elastic.co/t/access-to-filter-values-in-script-kibana/273753/2 "2021-05-26T19:45:37Z")

</div>

Hi, where are you putting in this script? What "Advanced section" is this about? Can you provide a screenshot or an example of what you are trying to do with the search?

---

<div class="post-metadata">

### Author: ![AR\_2021](https://avatars.discourse-cdn.com/v4/letter/a/e8c25b/32.png) [@AR\_2021](https://discuss.elastic.co/u/AR_2021)
#### Post date: [June 3, 2021, 6:47am UTC](https://discuss.elastic.co/t/access-to-filter-values-in-script-kibana/273753/3 "2021-06-03T06:47:25Z")

</div>

Hi. Thanks for your reply.  
I mean when a want to create visualization like area plot(in kibana) in the right menu there is advance option witch can used for scripting. beside, in the filter bar on the top of page, we can apply the specific filter. I want to access the value of filter bar(witch user enter lately) for scripting in advance option. is there a variable or function or anything else to access filter value in scripting ???

---

<div class="post-metadata">

### Author: ![tmp13](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tmp13/32/78005_2.png) [@tmp13](https://discuss.elastic.co/u/tmp13)
#### Post date: [June 3, 2021, 7:15am UTC](https://discuss.elastic.co/t/access-to-filter-values-in-script-kibana/273753/4 "2021-06-03T07:15:59Z")

</div>

Hi

1. "Is there a way or a function to access the filter value in script" - i think no
2. "or any solution ?" - if you provide more information about task, may be....

task i mean what do you want get, or what problem you solve...

---

<div class="post-metadata">

### Author: ![AR\_2021](https://avatars.discourse-cdn.com/v4/letter/a/e8c25b/32.png) [@AR\_2021](https://discuss.elastic.co/u/AR_2021)
#### Post date: [June 3, 2021, 7:30am UTC](https://discuss.elastic.co/t/access-to-filter-values-in-script-kibana/273753/5 "2021-06-03T07:30:25Z")

</div>

Hi. Thanks for your replay and attention.  
I have two filed for ip range. one filed show start range and another show end of range. when the user enter a ip value in the filter bar, i want to show documents witch support the ip(the ip value be in between two fields ip )

---

<div class="post-metadata">

### Author: ![tmp13](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tmp13/32/78005_2.png) [@tmp13](https://discuss.elastic.co/u/tmp13)
#### Post date: [June 3, 2021, 4:59pm UTC](https://discuss.elastic.co/t/access-to-filter-values-in-script-kibana/273753/6 "2021-06-03T16:59:01Z")

</div>

Oh...  
If I had such a task, I would do the following:  
If its possible...

1. create index with mapping ip\_range:  
`PUT my-index { "mappings": { "properties": { "ip_range": { "type": "ip_range" } } } }`
2. Using bash or another tool get CIDR from start ip + end ip and reindex docs to new index.
3. Search with kibana like this  
ip\_range: "192.168.1.34"

---

<div class="post-metadata">

### Author: ![AR\_2021](https://avatars.discourse-cdn.com/v4/letter/a/e8c25b/32.png) [@AR\_2021](https://discuss.elastic.co/u/AR_2021)
#### Post date: [June 5, 2021, 8:37pm UTC](https://discuss.elastic.co/t/access-to-filter-values-in-script-kibana/273753/7 "2021-06-05T20:37:18Z")

</div>

Thanks for your time.  
Actually i have already CIDR but the problem is that kibana do not fully support of ip  
-range and cant comper ip(from filter) with a value of ip\_range fild. the only way i find is add keyword type to ip\_range type which becoming text and not supported ip type for compering.

---

<div class="post-metadata">

### Author: ![tmp13](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tmp13/32/78005_2.png) [@tmp13](https://discuss.elastic.co/u/tmp13)
#### Post date: [June 6, 2021, 7:38am UTC](https://discuss.elastic.co/t/access-to-filter-values-in-script-kibana/273753/8 "2021-06-06T07:38:33Z")

</div>

What version Elasticsearch, Kibana you use?  
If i right undestand problem....  
I test in 7.11.1

```
PUT my-index
{
  "mappings": {
    "properties": {
      "ip_range": {
        "type": "ip_range"
      }
    }
  }
}

PUT my-index/_doc/1
{
  "ip_range": "192.168.1.0/24"
}

PUT my-index/_doc/2
{
  "ip_range": "192.168.1.0/30"
}

PUT my-index/_doc/3
{
  "ip_range": "10.1.1.1/24"
}

```

Check with query:

```
GET my-index/_search
{
  "query": {
    "term": {
      "ip_range": {
        "value": "192.168.1.3"
      }
    }
  }
}

```

Ok return 2 hits:

```
"hits" : [
  {
    "_index" : "my-index",
    "_type" : "_doc",
    "_id" : "1",
    "_score" : 1.0,
    "_source" : {
      "ip_range" : "192.168.1.0/24"
    }
  },
  {
    "_index" : "my-index",
    "_type" : "_doc",
    "_id" : "2",
    "_score" : 1.0,
    "_source" : {
      "ip_range" : "192.168.1.0/30"
    }
  }
]

```

Then i add index pattern and use filter on panel:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/c/2c7a73b76c55244a7a60f0990378f2a378562144.png)

and i understand... may be...))  
You need use only this button??  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/7/d731d30f25ff99f648788ac1443d11ae446191d7.png)  
Why not text filter as in the first screenshot...

---

<div class="post-metadata">

### Author: ![AR\_2021](https://avatars.discourse-cdn.com/v4/letter/a/e8c25b/32.png) [@AR\_2021](https://discuss.elastic.co/u/AR_2021)
#### Post date: [June 8, 2021, 6:28am UTC](https://discuss.elastic.co/t/access-to-filter-values-in-script-kibana/273753/9 "2021-06-08T06:28:13Z")

</div>

Hi.  
I am so thankful for your time and kindness.  
you right its completely works. but in kibana the problem arise..  
in kibana when i want to create "index pattern" from this index the type of "ip\_range" will be unknown and when i want to visualize, couldn't see ip\_range field in metric or bucket sections. apparently until now kibana doesn't support ip\_range type.  
thanks so much

---

<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 6, 2021, 6:29am UTC](https://discuss.elastic.co/t/access-to-filter-values-in-script-kibana/273753/10 "2021-07-06T06:29:12Z")

</div>

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