# Update filter

**URL:** https://discuss.elastic.co/t/update-filter/85622
**Category:** Kibana
**Created:** [May 12, 2017, 9:00pm UTC](https://discuss.elastic.co/t/update-filter/85622 "2017-05-12T21:00:10Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Akaren](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@Akaren](https://discuss.elastic.co/u/Akaren)
#### Post date: [May 12, 2017, 9:00pm UTC](https://discuss.elastic.co/t/update-filter/85622/1 "2017-05-12T21:00:10Z")

</div>

Hi, I am creating my own special Kibana filter:  
_function createFilter(field){_  
\_ return{\_  
\_ meta: { \_  
\_ index: 'logstash\*', \_  
\_ alias: 'Type filter' \_  
\_ },\_  
\_ query:{\_  
\_ query\_string: { query: field}\_  
\_ }\_  
\_ }\_  
\_ }\_

I am using queryFilter.addFilters(filter); But I need to update my filter. I am little confused by updateFilter function:  
_queryFilter.updateFilter({_  
\_ source: filterOld,\_  
\_ model: filterNew,\_  
\_ type: 'query'\_  
\_ });\_

"source" should be old filter, "model" new one. But when I create filter (with my own function on the top of this text), it doesn't update it or add it.  
_var filterOld = createFilter("XXX");_  
_var filterNew = createFilter("YYY");_

What do I need to do for update? Thanks!

---

<div class="post-metadata">

### Author: ![Stacey\_Gammon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stacey_gammon/32/14025_2.png) [@Stacey\_Gammon](https://discuss.elastic.co/u/Stacey_Gammon)
#### Post date: [May 17, 2017, 11:46am UTC](https://discuss.elastic.co/t/update-filter/85622/2 "2017-05-17T11:46:17Z")

</div>

Taking a look at the code, the `updateFilter` call creates a new updated filter and returns it. It doesn't modify the filters passed in, and doesn't actually save anything to state. Are you adding the new updated filter to the state once you've created it?

---

<div class="post-metadata">

### Author: ![Akaren](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@Akaren](https://discuss.elastic.co/u/Akaren)
#### Post date: [May 17, 2017, 2:13pm UTC](https://discuss.elastic.co/t/update-filter/85622/3 "2017-05-17T14:13:06Z")

</div>

I've found out that I need to call queryFilter.addFilter twice. For old and new filter. But for me it doesn't make any sense to call it also for new filter because I just want to update new one (not "create" one).

---

<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 14, 2017, 2:13pm UTC](https://discuss.elastic.co/t/update-filter/85622/4 "2017-06-14T14:13:39Z")

</div>

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