Angular 4 - Get field name/types for several indexes

(the full stack is in v.5.3.0)
Hi, here's the thing:

I'm currently making a small angular 4 web app with a Kibana dashboard embedded. Things are working (kinda) great, I've managed to have a workaround for the filter bar, but now, I want to make filtering easier for the end-user.

What I ideally want, is to propose a drop-down list containing all text fields for the currently used list of index, and an input for the regex or value. (similar thing for number with maybe a slider).

For that, as I want a dynamic list, I'm currently using an API to query ES (see https://github.com/elastic/elasticsearch-js/issues/452 , relies on JS API)
I can get the answer of the query:

this._client.indices.getMapping( {
      index: 'logstash-*'
    })

(which is the same as: GET http://localhost:9200/logstash-*/_mapping)

Now the tricky thing (or at least, annoying for me), is to correctly parse this JSON to have all the different fields and type.
For instance:

...
"properties": {
          "@timestamp": {
            "type": "date",
            "include_in_all": false
          },
...

For getting the object inside timestamp, there's no problem, but for getting the fact that this decribes a field called @timestamp, I don't really know how to do it.

JSON.parse works, but how to access fields on this object?

So do you have any advice on how parse this JSON to have fields? Or maybe an easier/alternative way to do this?

For the moment, I try to discover key values and how to access them

(Btw, I've seen this: https://github.com/elastic/kibana/pull/11375 which is quite what I want, but it will appear in 5.5 or maybe 6.0, and I don't know when I will be updating to this (currently using plugins so I cannot upgrade right after the new version comes out), and I don't know how it will behave in embedded dashboard, but great anyway)

Ok, I just found out the working syntax to access key/value.

So you can consider my main "problem" (if you can call that a problem) solved.

But still, if someone knows a better way to get all fields name, don't hesitate

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