# How to use Jason input in Y axis to filter null values

**URL:** https://discuss.elastic.co/t/how-to-use-jason-input-in-y-axis-to-filter-null-values/159595
**Category:** Kibana
**Created:** [December 5, 2018, 7:52pm UTC](https://discuss.elastic.co/t/how-to-use-jason-input-in-y-axis-to-filter-null-values/159595 "2018-12-05T19:52:51Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![qub123](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/qub123/32/55327_2.png) [@qub123](https://discuss.elastic.co/u/qub123)
#### Post date: [December 5, 2018, 7:52pm UTC](https://discuss.elastic.co/t/how-to-use-jason-input-in-y-axis-to-filter-null-values/159595/1 "2018-12-05T19:52:52Z")

</div>

Hi ,

I would like to filter null value on a Y-axis for string type or date type in the advanced option “Json input “ . Just wondering how should I do it. I don’t want to do it on the “filter” part because I want all my y axis has OR condition. I am having error when putting script below

example: { "script" : "doc['job\_id'].value = null" }

example: { "script" : "doc['job\_date'].value = null" }

---

<div class="post-metadata">

### Author: ![Aaron\_Caldwell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron_caldwell/32/45755_2.png) [@Aaron\_Caldwell](https://discuss.elastic.co/u/Aaron_Caldwell)
#### Post date: [December 5, 2018, 10:42pm UTC](https://discuss.elastic.co/t/how-to-use-jason-input-in-y-axis-to-filter-null-values/159595/2 "2018-12-05T22:42:15Z")

</div>

Hello Kenneth,

It sounds like you want a bool query using `must` and `should` to effectively give you the OR logic you're after. When you create a filter, you can expand the filter to write custom Query DSL logic. From the documentation: "If the `bool` query is a [filter context](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-filter-context.html) or has neither `must` or `filter` then at least one of the `should` queries must match a document for it to match the `bool` query"

You'll find several examples of how to do this around in general, but to get you started:

- [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html)
- [https://stackoverflow.com/questions/28538760/elasticsearch-bool-query-combine-must-with-or](https://stackoverflow.com/questions/28538760/elasticsearch-bool-query-combine-must-with-or)

Regards,  
Aaron

---

<div class="post-metadata">

### Author: ![qub123](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/qub123/32/55327_2.png) [@qub123](https://discuss.elastic.co/u/qub123)
#### Post date: [December 5, 2018, 11:53pm UTC](https://discuss.elastic.co/t/how-to-use-jason-input-in-y-axis-to-filter-null-values/159595/3 "2018-12-05T23:53:38Z")

</div>

Hi Aaron,

Thanks for your reply! But it is not about filtering, should or must or must\_not. It is not what I want to achieve, I tried all these options, didn't get the result i wanted. I want to know if "not\_exist" is supported?

I explained a bit on my scenario below, I have some ES doc that contains different fields, some with null values, some with values. I want to get the count of the field for "not\_exists" values. Please check my example below.

**Wanted Behavior**  
"bool": {  
" **should**": [  
{  
" **not\_exists**": {  
"field": "queue\_event\_id"  
}  
},  
{  
" **not\_exists**": {  
"field": "start\_event\_id"  
}  
},  
{  
" **not\_exists**": {  
"field": "finish\_event\_id"  
}  
}  
]  
}

**Elastic Search Documents Example**  
_ES doc1_  
domain\_id = host123  
queue\_event\_id = a123  
start\_event\_id = a234  
finish\_event\_id = a345

_ES doc2_  
domain\_id = host123  
queue\_event\_id = b123  
start\_event\_id = b234  
finish\_event\_id = b345

_ES doc3_  
domain\_id = host123  
queue\_event\_id = null  
start\_event\_id = c234  
finish\_event\_id = null

_ES doc4_  
domain\_id = host123  
queue\_event\_id = d123  
start\_event\_id = null  
finish\_event\_id = null

**My Kibana Graph Configuration**  
_I have 3 y axis in my graph_  
y1-uniquecount (queue\_event\_id)  
y2-uniquecount (start\_event\_id)  
y3-uniquecount (finish\_event\_id)

_x axis_  
x-singnificant term (domain\_id)

**My Expected Result**  
expected result for those id that contains "null" value for domain host123 is

* * *

number of not\_exist --- queue\_event\_id = 1  
number of not\_exist --- start\_event\_id = 1  
number of not\_exist --- finish\_event\_id = 2

The query below with "must\_not" will give me 0 result for everything, since it is AND condition. If I want to use "should" condition, then I need a "not\_exists" tag , but not\_exist tag is not supported

```
{
  "query": {
    "bool": {
      "must_not": [
        {
          "exists": {
            "field": "queue_event_id"
          }
        },
        {
          "exists": {
            "field": "start_event_id"
          }
        },
        {
          "exists": {
            "field": "finish_event_id"
          }
        }
      ]
    }
  }
}
```

---

<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 2, 2019, 11:53pm UTC](https://discuss.elastic.co/t/how-to-use-jason-input-in-y-axis-to-filter-null-values/159595/4 "2019-01-02T23:53:43Z")

</div>

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