I'm writing a thin proxy server to sit in front of ElasticSearch,
using the java client API. The proxy constructs a query, sends it off
to ElasticSearch, and returns the results to the proxy client.
Pretty simple, but I'm struggling with how to take the SearchResponse
and get it to stream itself as JSON to the proxy's HTTP response. The
ToXContent and Streamable interfaces seem to only work with low-level
data, not JSON. The cloest I can get to is
... but of course, this writes gibberish to the stream, nut human-
readable JSON.
Am I looking in the wrong place?
I'm considering using the REST client inside the proxy instead, but it
seems a shame to forgo the extra performance of the Java Node client,
given that the proxy is written in Java.
I'm writing a thin proxy server to sit in front of Elasticsearch,
using the java client API. The proxy constructs a query, sends it off
to Elasticsearch, and returns the results to the proxy client.
Pretty simple, but I'm struggling with how to take the SearchResponse
and get it to stream itself as JSON to the proxy's HTTP response. The
ToXContent and Streamable interfaces seem to only work with low-level
data, not JSON. The cloest I can get to is
... but of course, this writes gibberish to the stream, nut human-
readable JSON.
Am I looking in the wrong place?
I'm considering using the REST client inside the proxy instead, but it
seems a shame to forgo the extra performance of the Java Node client,
given that the proxy is written in Java.
It does, however, mean shifting one in-memory representation to
another before streaming it out, which could be a bottleneck. It would
nice if it could be streamed out directly.
I'm writing a thin proxy server to sit in front of Elasticsearch,
using the java client API. The proxy constructs a query, sends it off
to Elasticsearch, and returns the results to the proxy client.
Pretty simple, but I'm struggling with how to take the SearchResponse
and get it to stream itself as JSON to the proxy's HTTP response. The
ToXContent and Streamable interfaces seem to only work with low-level
data, not JSON. The cloest I can get to is
... but of course, this writes gibberish to the stream, nut human-
readable JSON.
Am I looking in the wrong place?
I'm considering using the REST client inside the proxy instead, but it
seems a shame to forgo the extra performance of the Java Node client,
given that the proxy is written in Java.
I'll add a constructor to XContentBuilder, so you can
do: XContentBuilder(XContent xContent, OutputStream bos). Just make sure to
call close on the builder when you are done with it.
in ES, I generate the bytes into thread local byte buffer, and then reuse it
on the networking layer. Thats why the unsafeBytes / unsafeBytesLength are
there on the builder. Don't know which network lib you use..., but the
OutputStream option should be good on servlet envs.
It does, however, mean shifting one in-memory representation to
another before streaming it out, which could be a bottleneck. It would
nice if it could be streamed out directly.
I'm writing a thin proxy server to sit in front of Elasticsearch,
using the java client API. The proxy constructs a query, sends it off
to Elasticsearch, and returns the results to the proxy client.
Pretty simple, but I'm struggling with how to take the SearchResponse
and get it to stream itself as JSON to the proxy's HTTP response. The
ToXContent and Streamable interfaces seem to only work with low-level
data, not JSON. The cloest I can get to is
... but of course, this writes gibberish to the stream, nut human-
readable JSON.
Am I looking in the wrong place?
I'm considering using the REST client inside the proxy instead, but it
seems a shame to forgo the extra performance of the Java Node client,
given that the proxy is written in Java.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.