Wednesday, November 22, 2017

ElasticSearch for YAML lovers

By default the output returned by ElasticSearch is JSON. However if you like the more dense format that YAML offers, it is possible  to ask ElasticSearch to output your data as YAML. Just add  ‘format=yaml’ as a querystring parameter to your query:

GET nusearch/package/_search?format=yaml
{
  "suggest": {
    "package-suggestions": {
      "prefix": "asp",
      "completion": {
        "field": "suggest"
      }
    }
  },
  "_source": {
    "includes": [
      "id",
      "downloadCount",
      "summary"
    ]
  }
}

Your output will become:

image

No comments: