Hi,
when i use the match query like below:
GET test/_search
{
"query": {
"match": {
"name": "elastic"
}
}
}
The response is :
{
"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:
POST /_sql?format=json
{
"query": "SELECT * FROM test "
}
The response comes like below and it is very difficult to read:
{"columns":[{"name":"name","type":"text"}],"rows":[["elastic"]]}
I want to get the json line after line like below:
{
"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!
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!
dadoonet
(David Pilato)
June 27, 2019, 11:37am
4
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.
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!
dadoonet
(David Pilato)
June 27, 2019, 2:03pm
6
Q1: yes
Q2: if you are using curl
you can use jq
to format it.
Thanks david.
Can I know by when the issue will be fixed?
No David.
Can i know how to open an issue regarding this. Thanks!
dadoonet
(David Pilato)
June 28, 2019, 5:49am
10
Thanks Andrei and David.
Can I know in which version this issue has been fixed ?
Hi David and Andrei,
Would like to know whether this issue has been addressed in elastic 7.2 version. Thanks!
dadoonet
(David Pilato)
July 1, 2019, 8:20am
14
It's not merged so it's not available anywhere yet.
Thanks david.
Whether this will available in upcoming version i.e 7.3 ?
dadoonet
(David Pilato)
July 1, 2019, 9:26am
16
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?
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?
dadoonet
(David Pilato)
July 1, 2019, 10:14am
18
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?
system
(system)
Closed
July 29, 2019, 10:15am
19
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.