Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

318
Views
elasticsearch: convert StreamOutput to String

I'm overriding FilterClient so I can see incoming requests. I'd like some way to get a String representation of the ActionRequest that's passed in. ActionRequest let's you write to a StreamOuput, which is an Elasticsearch type that is a subclass of OutputStream. This SO post shows how to convert OutputStream to a String, but I'm forced to use StreamOuput due to the FilterClient API.

How do I get a String representation of ActionRequest or at least a readable version that will show me useful information about the request? (Calling ActionRequest.toString calls Object.toString, which is not good enough for me.)

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

StreamOutput is an abstract class which has a subclass called OutputStreamStreamOutput. The latter is basically a wrapper around an OutputStream, so you'd create an instance that wraps a ByteArrayOutputStream and then use it in the ActionRequest.writeTo() call.

// in your override doExecute method, add this:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStreamStreamOutput osso = new OutputStreamStreamOutput(baos);

request.writeTo(osso);
String requestAsString = baos.toString("UTF-8");
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!