Kibana: Support YAML in Dev Tools -> Console

Created on 15 Jan 2019  路  7Comments  路  Source: elastic/kibana

Describe the feature: Most APIs of Elasticsearch support YAML requests and ES can send responses also in YAML. Please consider supporting it also in Dev Tools -> Console. For completeness, "raw" filter blocks ("Edit Query DSL") should then also support YAML.

Describe a specific use case for the feature:

Stages of implementation

  • [ ] Basic support to accept YAML as request. (ES supports this so you just need to set the Content-Type: application/yaml in the request. ES will then also answer YAML encoded.)
  • [ ] Folding support.
  • [ ] Optional, might be out of scope: Conversion between YAML and JSON in the Console to have the best of both worlds.
  • [ ] Request completion.

Example:

GET index/_search
---

size: 5

_source:
  - 'license'
  - 'name'

query:
  query_string:
    query: '+license:("GPL-3.0-only" OR "AGPL-3.0-only")'
...
Console Dev Tools Elasticsearch UI enhancement good first issue

Most helpful comment

I am taking the Engineer I training right now, and was thinking this would be great to have.

To elaborate on the "human editable and readable" part, YAML support would allow for much more concise queries while cutting down on the need for fiddly braces, quote marks, and commas.

For example, this:

GET blogs/_search
{
  "query": {
    "match": {
      "title": {
        "query": "open source software",
        "minimum_should_match": 2
      }
    }
  }
}

Becomes:

GET blogs/_search
query:
    match:
        title:
            query: "open source software"
            minimum_should_match: 2

All 7 comments

Pinging @elastic/es-ui

@ypid-geberit
Thank you for opening this issue. Any other reason for using YAML other than the two you have mentioned above?

I might add that I use YAML all over the place together with Elasticsearch. For example to write ES watches (https://github.com/elastic/examples/pull/239) and thus also for queries. When you use Curator, you also end up writing queries in YAML. YAML is already present in Elasticsearch and people know/use it. Even the configuration file of Kibana is in YAML.

To summaries this:

  • YAML is known to people from other places in the Elastic Stack.

That is a third reason but the two reasons I mentioned already are my main reasons. I can go into more depth on those two if you want to.

I am taking the Engineer I training right now, and was thinking this would be great to have.

To elaborate on the "human editable and readable" part, YAML support would allow for much more concise queries while cutting down on the need for fiddly braces, quote marks, and commas.

For example, this:

GET blogs/_search
{
  "query": {
    "match": {
      "title": {
        "query": "open source software",
        "minimum_should_match": 2
      }
    }
  }
}

Becomes:

GET blogs/_search
query:
    match:
        title:
            query: "open source software"
            minimum_should_match: 2

^ or even:

GET blogs/_search
query.match.title.query: "open source software"
query.match.title.minimum_should_match: 2

I'd love this feature. I spend about 50% of my time counting closing brackets.

Another good reason could be to have multiline strings for scripts in YAML.

GET hockey/_search
{
  "query": {
    "match_all": {}
  },
  "script_fields": {
    "total_goals": {
      "script": {
        "lang": "painless",
        "source": "int total = 0; for (int i = 0; i < doc['goals'].length; ++i) { total += doc['goals'][i]; } return total;"
      }
    }
  }
}

becomes:

query:
  match_all: {}
script_fields:
  total_goals:
    script:
      lang: painless
      source: >
                     int total = 0; 
                     for (int i = 0; i < doc['goals'].length; ++i) { 
                         total+= doc['goals'][i]; 
                     } 
                     return total;
Was this page helpful?
0 / 5 - 0 ratings

Related issues

stacey-gammon picture stacey-gammon  路  3Comments

MaartenUreel picture MaartenUreel  路  3Comments

cafuego picture cafuego  路  3Comments

ynux picture ynux  路  3Comments

timmolter picture timmolter  路  3Comments