-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

1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

7 Comments

Thanq. But how could i use this with the help of Httpclient. Could u please help me.
You might find your answer here.
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.
You have to update your question explaining what you intend to do no answer in a comment
The Java API page hyperlink is incorrect, the underscore after the word index needs to be removed, the correct link
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.