# Need suggestions on few concerns

**URL:** <https://discuss.elastic.co/t/need-suggestions-on-few-concerns/8524>\
**Category:** Elasticsearch\
**Created:** [July 26, 2012, 11:26am UTC](https://discuss.elastic.co/t/need-suggestions-on-few-concerns/8524 "2012-07-26T11:26:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yachana](https://avatars.discourse-cdn.com/v4/letter/y/3ec8ea/32.png) [@yachana](https://discuss.elastic.co/u/yachana)\
**Post date:** [July 26, 2012, 11:26am UTC](https://discuss.elastic.co/t/need-suggestions-on-few-concerns/8524/1 "2012-07-26T11:26:01Z")

</div>

Hi ES team,

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](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

Thanks in advance  
yachana

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [July 27, 2012, 11:09am UTC](https://discuss.elastic.co/t/need-suggestions-on-few-concerns/8524/2 "2012-07-27T11:09:14Z")

</div>

Hi Yachana,

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:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

> \*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.

Martijn

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:18am UTC](https://discuss.elastic.co/t/need-suggestions-on-few-concerns/8524/3 "2017-07-06T03:18:48Z")

</div>


