# Kibana filter on dashboard not working for Vega

**URL:** <https://discuss.elastic.co/t/kibana-filter-on-dashboard-not-working-for-vega/311107>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [August 1, 2022, 11:37am UTC](https://discuss.elastic.co/t/kibana-filter-on-dashboard-not-working-for-vega/311107 "2022-08-01T11:37:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pranay\_jain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pranay_jain/32/92747_2.png) [@pranay\_jain](https://discuss.elastic.co/u/pranay_jain)\
**Post date:** [August 1, 2022, 11:37am UTC](https://discuss.elastic.co/t/kibana-filter-on-dashboard-not-working-for-vega/311107/1 "2022-08-01T11:37:18Z")

</div>

I have a index named 'employees' with following mapping

```auto
"properties": {
  "employee_id": {
    "type": "long"
  },
  "employee_details": {
    "type": "nested",
    "dynamic": "false",
    "properties": {
      "city": {
        "type": "keyword"
      },
      "employee_type": {
        "type": "keyword"
      }
    }
  }
}

```

Based on the index documents, I have created kibana dashboard with multiple widgets in it.  
I noticed that we can filter the data in the dashboard using KQL

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/3/43d1c1005f9ff46414b4b33e051172e5d5a8bfcb.png)

or using filters

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/0/60b31e14539ab28fa22ec3d3f9ebe508361ae7f9.png)

Problem:  
I noticed that the query generated by using KQL and Filter is different for Vega widgets.

For KQL the query was as below which is correct.

```auto
{
  "aggs": {},
  "size": 0,
  "query": {
    "bool": {
      "must": [],
      "filter": [
        {
          "nested": {
            "path": "employee_details",
            "query": {
              "bool": {
                "should": [
                  {
                    "match_phrase": {
                      "employee_details.employee_type": "PERMANENT"
                    }
                  }
                ],
                "minimum_should_match": 1
              }
            },
            "score_mode": "none"
          }
        }
      ]
    }
  }
}

```

But the query generated using the filter is incorrect for Vega widgets

```auto
{  
  "size": 0,
  "query": {
    "bool": {
      "filter": [
        {
          "match_phrase": {
            "employee_details.employee_type": "PERMANENT"
          }
        }
      ],
      "should": [],
      "must_not": []
    }
  }
}

```

I failed to understand why these queries are different only for Kibana widgets.  
Can somebody please help?

---

<div class="post-metadata">

**Author:** ![Marta\_Bondyra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marta_bondyra/32/102122_2.png) [@Marta\_Bondyra](https://discuss.elastic.co/u/Marta_Bondyra)\
**Post date:** [August 12, 2022, 7:49am UTC](https://discuss.elastic.co/t/kibana-filter-on-dashboard-not-working-for-vega/311107/2 "2022-08-12T07:49:07Z")

</div>

Hey there, did you pass Kibana context to your Vega script? `"%context%": true`

 ![Screenshot 2022-08-12 at 09.48.17](https://us1.discourse-cdn.com/elastic/original/3X/6/8/68f35e45143278cef44168e7213ae2f912aa7a4f.png)

---

<div class="post-metadata">

**Author:** ![pranay\_jain](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pranay_jain/32/92747_2.png) [@pranay\_jain](https://discuss.elastic.co/u/pranay_jain)\
**Post date:** [August 16, 2022, 7:15am UTC](https://discuss.elastic.co/t/kibana-filter-on-dashboard-not-working-for-vega/311107/3 "2022-08-16T07:15:53Z")

</div>

Yes, I already pass the "%context%": true property in vega chart

---

<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:** [September 13, 2022, 7:16am UTC](https://discuss.elastic.co/t/kibana-filter-on-dashboard-not-working-for-vega/311107/4 "2022-09-13T07:16:05Z")

</div>

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