# Kibana vega context and timefield

**URL:** <https://discuss.elastic.co/t/kibana-vega-context-and-timefield/295102>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [January 21, 2022, 11:34pm UTC](https://discuss.elastic.co/t/kibana-vega-context-and-timefield/295102 "2022-01-21T23:34:17Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)\
**Post date:** [January 22, 2022, 11:24pm UTC](https://discuss.elastic.co/t/kibana-vega-context-and-timefield/295102/6 "2022-01-22T23:24:43Z")

</div>

> [@Tingda\_Du](#):
>
> What will be the way to filter by dashboard time in this case?

I suppose the only way to use context and timefield filtering is to implement the query using only aggregation.

If you used query clause to filter documents, you can use [Filter aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html) instead of query clause.

If you use "hits" of the query for formatter in vega-lite, it seems difficult but using filter aggregation with [scripted metric aggregation "trick"](https://discuss.elastic.co/t/how-to-aggregate-data-on-elastic-sent-by-logstash/205140/2) to retrieve all documents in a bucket could be a possible choice though I have not tried.

> [@Tingda\_Du](#):
>
> This possibility is 0

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/5/f577c3eed985bed9a4d428c397593f07181bb4ca.png)

I see. Please check the Request and Response in Inspector. Are there buckets as you expected?

---

_[View the full topic](https://discuss.elastic.co/t/kibana-vega-context-and-timefield/295102)._
