elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.69k stars 8.24k forks source link

Support YAML in Dev Tools -> Console #28754

Open ypid-geberit opened 5 years ago

ypid-geberit commented 5 years ago

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

Example:

GET index/_search
---

size: 5

_source:
  - 'license'
  - 'name'

query:
  query_string:
    query: '+license:("GPL-3.0-only" OR "AGPL-3.0-only")'
...
elasticmachine commented 5 years ago

Pinging @elastic/es-ui

yaronp68 commented 5 years ago

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

ypid-geberit commented 5 years ago

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:

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.

CommanderTso commented 5 years ago

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
tdmalone commented 5 years ago

^ or even:

GET blogs/_search
query.match.title.query: "open source software"
query.match.title.minimum_should_match: 2
phoerious commented 5 years ago

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

yosbeleg89 commented 4 years ago

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;
i0 commented 3 years ago

Please consider adding this feature!

elasticmachine commented 2 months ago

Pinging @elastic/kibana-management (Team:Kibana Management)