Dashboard in vega query elasticsearch and a fixed

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

 {
  "$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:

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

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



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

Never tried this in Vega-Lite but in Vega you can easily do this with the source property.

{
  "$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

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?

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

There are some examples in the documentation.

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.

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.

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