# Elasticsearch sql response change

**URL:** <https://discuss.elastic.co/t/elasticsearch-sql-response-change/187730>\
**Category:** Elasticsearch\
**Created:** [June 27, 2019, 6:16am UTC](https://discuss.elastic.co/t/elasticsearch-sql-response-change/187730 "2019-06-27T06:16:07Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![SukeshGupta](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@SukeshGupta](https://discuss.elastic.co/u/SukeshGupta)\
**Post date:** [June 27, 2019, 6:16am UTC](https://discuss.elastic.co/t/elasticsearch-sql-response-change/187730/1 "2019-06-27T06:16:07Z")

</div>

Hi,

when i use the match query like below:

```auto
GET test/_search
{
  "query": {
    "match": {
      "name": "elastic"
    }
  }
}

```

The response is :

```auto
{
  "took" : 2,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 0.2876821,
    "hits" : [
      {
        "_index" : "test",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 0.2876821,
        "_source" : {
          "name" : "elastic"
        }
      }
    ]
  }
}

```

But when i use elasticsearch sql query:

```auto
POST /_sql?format=json
{
"query": "SELECT * FROM test "
}

```

The response comes like below and it is very difficult to read:

```auto
{"columns":[{"name":"name","type":"text"}],"rows":[["elastic"]]}

```

I want to get the json line after line like below:

```auto
{
"columns":[
{
"name":"name",
"type":"text"
}
],
"rows":[
["elastic"]]
}

```

Can you please tell how to get the response like above when we use sql. Beacause it will be helpful for to read. Thanks!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 27, 2019, 6:55am UTC](https://discuss.elastic.co/t/elasticsearch-sql-response-change/187730/2 "2019-06-27T06:55:53Z")

</div>

Try to add `pretty=true`

---

<div class="post-metadata">

**Author:** ![SukeshGupta](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@SukeshGupta](https://discuss.elastic.co/u/SukeshGupta)\
**Post date:** [June 27, 2019, 10:25am UTC](https://discuss.elastic.co/t/elasticsearch-sql-response-change/187730/3 "2019-06-27T10:25:55Z")

</div>

Thanks david for the reply.

I tried adding pretty=true. It will not work.  
Can you please help me in which way we can do this. Thanks!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 27, 2019, 11:37am UTC](https://discuss.elastic.co/t/elasticsearch-sql-response-change/187730/4 "2019-06-27T11:37:56Z")

</div>

Just tested it and indeed it does not change the output.  
Would you like to open an issue for this?

I did not see that `pretty` is not supported in the REST API so IMHO it might be either a documentation issue or a real issue we would like to fix.

---

<div class="post-metadata">

**Author:** ![SukeshGupta](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@SukeshGupta](https://discuss.elastic.co/u/SukeshGupta)\
**Post date:** [June 27, 2019, 12:55pm UTC](https://discuss.elastic.co/t/elasticsearch-sql-response-change/187730/5 "2019-06-27T12:55:01Z")

</div>

Thanks for your reply David.

Q1 : Is it the issue from elastic side ?

Q2: Is there any other way that the response can be changed? Thanks!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 27, 2019, 2:03pm UTC](https://discuss.elastic.co/t/elasticsearch-sql-response-change/187730/6 "2019-06-27T14:03:02Z")

</div>

Q1: yes

Q2: if you are using `curl` you can use `jq` to format it.

---

<div class="post-metadata">

**Author:** ![SukeshGupta](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@SukeshGupta](https://discuss.elastic.co/u/SukeshGupta)\
**Post date:** [June 27, 2019, 2:34pm UTC](https://discuss.elastic.co/t/elasticsearch-sql-response-change/187730/7 "2019-06-27T14:34:55Z")

</div>

Thanks david.

Can I know by when the issue will be fixed?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 27, 2019, 3:24pm UTC](https://discuss.elastic.co/t/elasticsearch-sql-response-change/187730/8 "2019-06-27T15:24:24Z")

</div>

Did you open it?

---

<div class="post-metadata">

**Author:** ![SukeshGupta](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@SukeshGupta](https://discuss.elastic.co/u/SukeshGupta)\
**Post date:** [June 28, 2019, 4:28am UTC](https://discuss.elastic.co/t/elasticsearch-sql-response-change/187730/9 "2019-06-28T04:28:36Z")

</div>

No David.

Can i know how to open an issue regarding this. Thanks!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 28, 2019, 5:49am UTC](https://discuss.elastic.co/t/elasticsearch-sql-response-change/187730/10 "2019-06-28T05:49:20Z")

</div>

Here you can open an issue [https://github.com/elastic/elasticsearch](https://github.com/elastic/elasticsearch)

---

<div class="post-metadata">

**Author:** ![Andrei\_Stefan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrei_stefan/32/47533_2.png) [@Andrei\_Stefan](https://discuss.elastic.co/u/Andrei_Stefan)\
**Post date:** [June 28, 2019, 4:08pm UTC](https://discuss.elastic.co/t/elasticsearch-sql-response-change/187730/11 "2019-06-28T16:08:04Z")

</div>

No need to create an issue. PR up already: [https://github.com/elastic/elasticsearch/pull/43756](https://github.com/elastic/elasticsearch/pull/43756)

---

<div class="post-metadata">

**Author:** ![SukeshGupta](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@SukeshGupta](https://discuss.elastic.co/u/SukeshGupta)\
**Post date:** [June 28, 2019, 5:12pm UTC](https://discuss.elastic.co/t/elasticsearch-sql-response-change/187730/12 "2019-06-28T17:12:08Z")

</div>

Thanks Andrei and David.

Can I know in which version this issue has been fixed ?

---

<div class="post-metadata">

**Author:** ![SukeshGupta](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@SukeshGupta](https://discuss.elastic.co/u/SukeshGupta)\
**Post date:** [July 1, 2019, 5:27am UTC](https://discuss.elastic.co/t/elasticsearch-sql-response-change/187730/13 "2019-07-01T05:27:22Z")

</div>

Hi David and Andrei,

Would like to know whether this issue has been addressed in elastic 7.2 version. Thanks!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 1, 2019, 8:20am UTC](https://discuss.elastic.co/t/elasticsearch-sql-response-change/187730/14 "2019-07-01T08:20:48Z")

</div>

It's not merged so it's not available anywhere yet.

---

<div class="post-metadata">

**Author:** ![SukeshGupta](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@SukeshGupta](https://discuss.elastic.co/u/SukeshGupta)\
**Post date:** [July 1, 2019, 9:02am UTC](https://discuss.elastic.co/t/elasticsearch-sql-response-change/187730/15 "2019-07-01T09:02:13Z")

</div>

Thanks david.

Whether this will available in upcoming version i.e 7.3 ?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 1, 2019, 9:26am UTC](https://discuss.elastic.co/t/elasticsearch-sql-response-change/187730/16 "2019-07-01T09:26:25Z")

</div>

No idea. Follow the issue and you will see when it's merged in which version it goes.

I'd say that I don't see anything critical here as using pretty is only to help humans to read this content. I agree that's a bug but why do you absolutely need it?

---

<div class="post-metadata">

**Author:** ![SukeshGupta](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@SukeshGupta](https://discuss.elastic.co/u/SukeshGupta)\
**Post date:** [July 1, 2019, 9:29am UTC](https://discuss.elastic.co/t/elasticsearch-sql-response-change/187730/17 "2019-07-01T09:29:28Z")

</div>

David we need to show it to clients. Hence it would be helpful if it comes in a proper json format.

Is it possible to extend any elastic api's and change the resonse accordingly through Java?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 1, 2019, 10:14am UTC](https://discuss.elastic.co/t/elasticsearch-sql-response-change/187730/18 "2019-07-01T10:14:53Z")

</div>

You can always write your own application which calls elasticsearch endpoint and rewrite whatever you need to whatever format.

I'm curious about what you are doing though.

A client should never read a JSON content. Are you providing something like an API to your users?  
And why are you using SQL instead of the `_search` endpoint?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 29, 2019, 10:15am UTC](https://discuss.elastic.co/t/elasticsearch-sql-response-change/187730/19 "2019-07-29T10:15:05Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
