Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pretty Print for Requests #188

Closed
sundarv85 opened this issue Dec 30, 2015 · 2 comments
Closed

Pretty Print for Requests #188

sundarv85 opened this issue Dec 30, 2015 · 2 comments

Comments

@sundarv85
Copy link

Hello,

I have enabled elastic.SetTraceLog(log.New(os.Stdout, "", log.LstdFlags)) and have set the Pretty as true

    searchResult, err := client.Search().
        Index("twitter"). // search in index "twitter"
        Query(termQuery). // specify the query
        From(0).Size(10). // take documents 0-9
        Pretty(true).     // pretty print request and response JSON
        Do()    

This prints the response in the pretty format. However the request is not pretty. I’m using "gopkg.in/olivere/elastic.v3"

@olivere
Copy link
Owner

olivere commented Dec 30, 2015

@sundarv85 You're right. Using Pretty(true) simply makes Elastic pass pretty=true as a URL query parameter to Elasticsearch. So in the end, Elasticsearch will pretty print the response and I simply output the pretty-printed response. Elastic doesn't do anything to pretty print anything, neither request nor response. So it first of all is a documentation issue.

I will have to dig into net/http/httputil to see if there's anything I can do to get the HTTP request pretty printed.

@olivere
Copy link
Owner

olivere commented Apr 30, 2016

I think I'll not be doing pretty-printing for the request side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants