# Dashboard in vega query elasticsearch and a fixed

**URL:** <https://discuss.elastic.co/t/dashboard-in-vega-query-elasticsearch-and-a-fixed/269075>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [April 1, 2021, 7:04pm UTC](https://discuss.elastic.co/t/dashboard-in-vega-query-elasticsearch-and-a-fixed/269075 "2021-04-01T19:04:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![francieliton\_araujo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/francieliton_araujo/32/47771_2.png) [@francieliton\_araujo](https://discuss.elastic.co/u/francieliton_araujo)\
**Post date:** [April 1, 2021, 7:04pm UTC](https://discuss.elastic.co/t/dashboard-in-vega-query-elasticsearch-and-a-fixed/269075/1 "2021-04-01T19:04:30Z")

</div>

how to create a dashboard in vega sound an elasticsearch query and a fixed value.

```auto
 {
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "description": "A simple pie chart with labels.",
  "data": {
    "values": [
      {"category": "a", "value": 4},
      {"category": "b", "value": 6}      
    ]
  },
  "encoding": {
    "theta": {"field": "value", "type": "quantitative", "stack": true},
    "color": {"field": "category", "type": "nominal", "legend": null}
  },
  "layer": [{
    "mark": {"type": "arc", "outerRadius": 80}
  }, {
    "mark": {"type": "text", "radius": 90},
    "encoding": {
      "text": {"field": "category", "type": "nominal"}
    }
  }],
  "view": {"stroke": null}
}

```

I would like to leave one of the values ​​fixed and the other taken from a query but not without how to do it:  
I need something like this:

```auto
"values": [
      {"category": "a",    

{
  "query": {
    "constant_score": {
      "filter": {
         "terms": {
          "objectid": [
            143009,
            122862
          ]
        }
      }
    }
  },
  "aggs": {
    "parada": { "sum": { "field": "seg" } }
  }
}

},
      {"category": "b", "value": 6}      
    ]

```

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [April 1, 2021, 7:47pm UTC](https://discuss.elastic.co/t/dashboard-in-vega-query-elasticsearch-and-a-fixed/269075/2 "2021-04-01T19:47:56Z")

</div>

Never tried this in Vega-Lite but in Vega you can easily do this with the [source](https://vega.github.io/vega/docs/data/) property.

```auto
{
  "$schema": "https://vega.github.io/schema/vega/v5.json",
  "data": [
    {
      "name": "static-field",
      "values": [{"category": "a", "value": 4}]
    },
    {
      "name": "simulated-es-query",
      "values": [{"category": "b", "value": 6}]
    },
    {
      "name": "combined",
      "source": ["static-field", "simulated-es-query"]
    }    
  ]
}

```

**Output**

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

---

<div class="post-metadata">

**Author:** ![francieliton\_araujo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/francieliton_araujo/32/47771_2.png) [@francieliton\_araujo](https://discuss.elastic.co/u/francieliton_araujo)\
**Post date:** [April 3, 2021, 2:20am UTC](https://discuss.elastic.co/t/dashboard-in-vega-query-elasticsearch-and-a-fixed/269075/3 "2021-04-03T02:20:05Z")

</div>

> [@aaron-nimocks](#):
>
> isso facilmente com a proprieda

I understand. however my difficulty is how and where to place a query elasticsearch within that code. please could you give a functional example with a query query elasticsearch?

---

<div class="post-metadata">

**Author:** ![Felix\_Roessel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felix_roessel/32/41623_2.png) [@Felix\_Roessel](https://discuss.elastic.co/u/Felix_Roessel)\
**Post date:** [April 3, 2021, 4:40am UTC](https://discuss.elastic.co/t/dashboard-in-vega-query-elasticsearch-and-a-fixed/269075/4 "2021-04-03T04:40:53Z")

</div>

Also check out the vega example library to find some ideas how it works..

> **[Kibana Vega examples | Download now at elastic content share](https://elastic-content-share.eu/downloads/category/kibana/kibana-vega-examples/)**
>
> Download pre build Kibana Vega examples for your Elasticsearch deployment.

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [April 3, 2021, 1:28pm UTC](https://discuss.elastic.co/t/dashboard-in-vega-query-elasticsearch-and-a-fixed/269075/5 "2021-04-03T13:28:53Z")

</div>

There are some examples in the [documentation](https://www.elastic.co/guide/en/kibana/current/vega.html#vega-queries).

---

<div class="post-metadata">

**Author:** ![francieliton\_araujo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/francieliton_araujo/32/47771_2.png) [@francieliton\_araujo](https://discuss.elastic.co/u/francieliton_araujo)\
**Post date:** [April 4, 2021, 12:29am UTC](https://discuss.elastic.co/t/dashboard-in-vega-query-elasticsearch-and-a-fixed/269075/6 "2021-04-04T00:29:07Z")

</div>

Sorry but there is no example, the way I want it, the examples from vega are too simple, I need that in a vega chart it has both an elastisearch query and also a fixed data. I am grateful if I can help.

---

<div class="post-metadata">

**Author:** ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)\
**Post date:** [April 4, 2021, 12:47pm UTC](https://discuss.elastic.co/t/dashboard-in-vega-query-elasticsearch-and-a-fixed/269075/7 "2021-04-04T12:47:33Z")

</div>

This would be more of an Elasticsearch query question vs a Vega question. Might want to post in that category because I am not sure if doing a query like you are looking for is possible.

---

<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:** [May 2, 2021, 12:47pm UTC](https://discuss.elastic.co/t/dashboard-in-vega-query-elasticsearch-and-a-fixed/269075/8 "2021-05-02T12:47:47Z")

</div>

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