Before I list out my concerns... I would like to congratulate complete ES team.. a very very well done job.. a great job.. elastic search is very cool.. & mainly I agree it is "cool, bonsai cool"
Wel, I m very new to this, but very much interested to use it , to continue please suggest me on the below concerns. 1. As per my under standing, we can query the index directly from
- HTTP url (http://localhost:9200/twittter/test/2)
- or from java API (.preparesearch)
- or from curl.
I m running http url from java code like below -
URL searchURL= new URL("input url.... ");
connection = searchURL.openConnection();
BufferedReader inputStream = new BufferedReader(new InputStreamReader(connection.getInputStream()));
..
.
.
.we dynamically form the URL ,execute and get the JSON object & use it.
Is it a rite way to do it? because, I see more examples only on curl. so, please suggest me which approach i can use .
2. Can we run curl from java class? is there any way?
3. is there any performance or execution difference between direct URL and Java API.
Totally my main concern is, I need to decide upon, How will we proceed, either URL, Java API or CURL.. please suggest me on the same,
If you find my concerns are silly, please excuse me..but need suggestions
From what I understand you're in a Java (jvm) environment. In that
situation I'd recommend to use the Java client.
If you your app is in the same network as the ES cluster then the Java
client is able to join the cluster as client.
This can result in more efficient network traffic since the client is
aware of the nodes in the cluster.
The http api actually wraps the Java client, so I'd say that using the
Java client directly in your app is more efficient.
On top of this the Java client has also a very easy to use api to
create search requests, index requests and other requests. More
information about the java client
can be found here:
*2. * Can we run curl from java class? is there any way?
I think you can execute curl bash command from Java using the JDK's
ProcessBuilder class. However I'd just use the Java client api b/c
that is much more convenient from a Java app.
3. is there any performance or execution difference between direct URL and
Java API.
I think the Java API is a bit more efficient to use compared than
using the http api via curl or something similar. You can even disable
the http interface in ES if you are only using the Java client.
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.