JAVA API Usage, Building SearchResponse object from JSON String


I am using ES 1.1.1 and Java 1.7u5. Deployed a intermediate WAR that queries Elasticsearch in Amazon EC2 instance. The problem with this approach is the querying is working fine for some time and after that there is no communication between WAR(tomcat) and ES !! This random failure is very uncomfortable. Now that this system is in dev, it is not a big problem.

Before the main problem is resolved, I am with the idea of using existing queries in Java with a minor modification. I plan to call ES on 9200(rest call) instead of TransportClient(9300 port) and parse the response string and build SearchResponse object. But I am not able to build valid StreamInput object from Http Response Stream.

If someone can throw some light on how to achieve this, this will be of great help.

Sri Harsha

Please upgrade. ES 1.1 is over a year old. Java 7u5 is also very old - 3 years - and there are many bugs fixed in the meantime. Note, Java 7 is no longer supported by Oracle, so I suggest to use latest Java 8 JDK.

There is no advantage of using HTTP in favor of Java protocol.

If you want help, you should post your Java code for examination and error analysis by the community.

I, also, am interested in creating a SearchResponse object from JSON. Our primary interface is a Java service which passes the HTTP response untouched from the ElasticSearch client to a JavaScript front end. For this reason, we cannot use the Java protocols.

However, we also need to connect to this same service from other Java services, as well as write Java integration tests for this service. At present, we are writing two copies of each endpoint, one for each protocol. However, this is increased engineering effort, and prohibits us from using our standard WS-RX Jersey Clients when testing the JSON endpoints, since we have no reliable way of serializing JSON back into Java objects.

I would like to assure you that we do have legitimate reasons for wanting to use HTTP, and would find it incredibly useful if there were a standard method to construct a SearchResponse object from a String of JSON.