Elasticsearch REST API 使用pretty

使用pretty如:

GET /website/blog/123?pretty

或者

PUT http://localhost:9200/colleges?pretty

作用:

在请求的查询串参数中加上 PRETTY 参数,正如前面的例子中看到的,这将会调用 ELASTICSEARCH 的 PRETTY-PRINT 功能,该功能使得 JSON 响应体更加可读。
但是, _SOURCE 字段不能被格式化打印出来。相反,我们得到的 _SOURCE 字段中的 JSON 串,刚好是和我们传给它的一样。

例如:


GET /website/blog/123?pretty

{
"_index" : "website", "_type" : "blog", "_id" : "123", "_version" : 1, "found" : true, "_source" : { "title": "My first blog entry", "text": "Just trying this out...", "date": "2014/01/01" } }

 

posted @ 2022-07-28 15:36  jason47  阅读(241)  评论(0编辑  收藏  举报