- Learning Elastic Stack 7.0(Second Edition)
- Pranav Shukla Sharath Kumar M N
- 121字
- 2025-04-04 14:18:53
Formatting the JSON response
By default, the response of all the requests is not formatted. It returns an unformatted JSON string in a single line:
curl -XGET http://localhost:9200/catalog/_doc/1
The following response is not formatted:
{"_index":"catalog","_type":"product","_id":"1","_version":3,"found":true,"_source":{
"sku": "SP000001",
"title": "Elasticsearch for Hadoop",
"description": "Elasticsearch for Hadoop",
"author": "Vishal Shukla",
"ISBN": "1785288997",
"price": 26.99
}}
Passing pretty=true formats the response:
curl -XGET http://localhost:9200/catalog/_doc/1?pretty=true
{
"_index" : "catalog",
"_type" : "product",
"_id" : "1",
"_version" : 3,
"found" : true,
"_source" : {
"sku" : "SP000001",
"title" : "Elasticsearch for Hadoop",
"description" : "Elasticsearch for Hadoop",
"author" : "Vishal Shukla",
"ISBN" : "1785288997",
"price" : 26.99
}
}
When you are using the Kibana Console UI, all responses are formatted by default.