-1

I am new to the Elastic Search. I had done insert, update and search through using CURL. I need to know how can I implement this by using java. Are there any methods?

Thank you

John Powell
  • 12,253
  • 6
  • 59
  • 67
user3816400
  • 19
  • 1
  • 2

1 Answers1

0

I will give you an example from elasticsearch official documentation :

import static org.elasticsearch.common.xcontent.XContentFactory.*;

IndexResponse response = client.prepareIndex("twitter", "tweet", "1")
    .setSource(jsonBuilder()
                .startObject()
                    .field("user", "kimchy")
                    .field("postDate", new Date())
                    .field("message", "trying out Elasticsearch")
                .endObject()
              )
    .execute()
    .actionGet();

For more details please check the official Elasticsearch Java API page.

eliasah
  • 39,588
  • 11
  • 124
  • 154
  • Thanq. But how could i use this with the help of Httpclient. Could u please help me. – user3816400 Jul 09 '14 at 09:11
  • You might find your answer [here](http://stackoverflow.com/questions/10441499/java-http-client-for-elasticsearch). – eliasah Jul 09 '14 at 09:31
  • HttpClientConfig cannot be resolved to a type: my code is: Client Config client Config = new Client Config.Builder(System. getenv ("http ://localhost:9200")) .multiThreaded(true).build(); How could i resolve this problem. can you please How to resolve this Client Config Builder cannot be resolved to a type. Could you please anyone help me. – user3816400 Jul 10 '14 at 09:45
  • You have to update your question explaining what you intend to do no answer in a comment – eliasah Jul 10 '14 at 09:46
  • I am trying to configure the jest client. But here am getting error as "HttpClientConfig cannot be resolved to a type".Is this problem with unavailable of jar file or anything else i need to know. can you please give me the solution. – user3816400 Jul 10 '14 at 11:20
  • 2
    The Java API page hyperlink is incorrect, the underscore after the word index needs to be removed, [the correct link](https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/index.html) – Harshad Vyawahare Jan 24 '18 at 13:32