3

I'm creating a desktop application (jar) where I need to add and search for information on elasticsearch. Elasticsearch is consumed using rest to get and set data and I'm thinking about use spark as I saw in the article below:

http://www.ibm.com/developerworks/library/j-use-elasticsearch-java-apps/index.html

Anyway, I have a doubt if I can do it on desktop applications or rest services can only be consumed by web applications.

Any other way to consume elasticsearch methods with java on desktop applications are welcome too.

I really appreciate any help. Thanks

Ranieri Mazili
  • 723
  • 6
  • 21

2 Answers2

2

You could also use RestTemplate from the Spring Framework. See this answer Issue When Consume Rest Service with RestTemplate in Desktop App.

Also, for elasticsearch Spring also has Spring Elasticsearch http://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/ or try Spring Solr, you could read some about it and their "differences" in here http://solr-vs-elasticsearch.com/

Hope this works for you =).

Community
  • 1
  • 1
Leo
  • 472
  • 5
  • 9
1

You will find a lot of examples on this online and there probably exists a lot of frameworks to make this simple. I have not tried Spark, but it looks OK. Apache HttpComponents Client is also a way to go and it's well proven. Example:

HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet('http://restUrl');
HttpResponse response = client.execute(request);

Here is some doc: http://hc.apache.org/httpcomponents-client-ga/

Einar
  • 181
  • 1
  • 7
  • 1
    But as @critcket_007 says, why not go for the Java SDK https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/index.html – Einar Dec 04 '16 at 20:31