# Is it possible to create a graph from a non array key/par object or transform it?

**URL:** https://discuss.elastic.co/t/is-it-possible-to-create-a-graph-from-a-non-array-key-par-object-or-transform-it/371125
**Category:** Kibana
**Tags:** vega
**Created:** [November 27, 2024, 8:56am UTC](https://discuss.elastic.co/t/is-it-possible-to-create-a-graph-from-a-non-array-key-par-object-or-transform-it/371125 "2024-11-27T08:56:48Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![pontual](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pontual/32/139512_2.png) [@pontual](https://discuss.elastic.co/u/pontual)
#### Post date: [November 27, 2024, 8:56am UTC](https://discuss.elastic.co/t/is-it-possible-to-create-a-graph-from-a-non-array-key-par-object-or-transform-it/371125/1 "2024-11-27T08:56:48Z")

</div>

Hi I'm using elastisearch 8.12 and I'm trying to create a graph that shows "the most used query string paramenters". I have a field in my index called "query" that has each possible value (query string paramenter) as a property field keyword.  
I aggregate the field "query" to count n how many documents they are present, like this:

```auto
{
  "size": 0,
  "aggs": {
    "A": {
      "value_count": {
        "field": "query.a.keyword"
      }
    },
    "B": {
      "value_count": {
        "field": "query.b.keyword"
      }
    },
    "C": {
      "value_count": {
        "field": "query.c.keyword"
      }
    }
  }
}

```

I can use "value\_count" or "filter/exists" but in any case, the result is generated like a key/value object, not as a "buckets" array, as below:

```auto
"aggregations": {
    "A": {
      "value": 71537
    },
    "B": {
      "value": 77386
    },
    "C": {
      "value": 71827
    }
  }

```

So I cannot realize how can I show each of those values (A, B, C, etc) in a graph. Is there a way to add multiple values to a graph axis?  
Or may another way to query or even tranform this (I've played around with the transform in the vega without success) to a array that can be showed as bar or lines graph, like this?

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

What I've done so far is the code below, but as expected, I can only have one value to be showed:

```auto
{

  $schema: https://vega.github.io/schema/vega-lite/v5.json
  title: Test

  // Define the data source
  data: {
    url: {

      // Apply dashboard context filters when set
      %context%: true
      // Filter the time picker (upper right corner) with this field
      %timefield%: @timestamp

      // Which index to search
      index: indexname
      // Aggregate data by the time field into time buckets, counting the number of documents in each bucket.
      body: {
        aggs: {
          "count_fields": {
            "global": {},
            "aggs": {
              "A": {
                "value_count": {
                  "field": "query.a.keyword"
                }
              },
              "B": {
                "value_count": {
                  "field": "query.b.keyword"
                }
              },
              "C": {
                "value_count": {
                  "field": "query.c.keyword"
                }
              }
            }
          }
        },
        // Speed up the response by only including aggregation results
        size: 0
      }
    }
  
    format: {property: "aggregations.count_fields"}
  
  }

  "mark": "text",
  "style": "text",
  "encoding": {"text": {"field": "A.value", "type": "string"}},
}

```

Thanks
