Query a nested object in elastic in kibana and display it to a table

18 views Asked by At

I want to create a very simple table , but my data is nested. Specifically I want to access the field "pids" inside a nested object called "components"

The field looks like this : components {components[{'content_type':'video','pid':'201'},{},{},{}],field2:...}

I can successfully get to the pid :

GET index-*/_search
{
  "_source":"",
  "query": {
    "nested": {
      "path": "components",
      "query": {
        "bool": {
          "must": [{"match_phrase": {"components.content_type": "Video"}}]
        }
      },
      "inner_hits": {
        "_source": "components.pid"
      }
    }
  }
}

The results returned look like this:

 "hits" : {
"total" : {
  "value" : 10000,
  "relation" : "gte"
},
"max_score" : 1.5403566,
"hits" : [
  {
    "_index" : "index-2024.02.05",
    "_type" : "_doc",
    "_id" : "2a2225837d43de515f11c6337d6b6f85",
    "_score" : 1.5403566,
    "_source" : { },
    "inner_hits" : {
      "components" : {
        "hits" : {
          "total" : {
            "value" : 1,
            "relation" : "eq"
          },
          "max_score" : 1.5403566,
          "hits" : [
            {
              "_index" : "index-2024.02.05",
              "_type" : "_doc",
              "_id" : "2a2225837d43de515f11c6337d6b6f85",
              "_nested" : {
                "field" : "components",
                "offset" : 3
              },
              "_score" : 1.5403566,
              "_source" : {
                "pid" : 201
              }
            }
          ]
        }
      }
    }
  },

Within Kibana Vega I can't seem to access

   format: {
  
  property:"hits.hits.inner_hits.components.hits"
 
  }

I believe I need this to get to pids

All I want to do is create a visual that is table like this:

PIDS
201
...
..
..

Do I need to use vega to do this and if so, I couldnt find any example of a simple table in https://vega.github.io/vega

0

There are 0 answers