How to index a document using Java REST client POST method


#1

Hi,

I want to index a document into amazonES . I am using Java REST client .
As per the documentation I found links to indexing a document as PUT method.

Map<String, String> params = Collections.emptyMap();
String jsonString = "{" +
            "\"user\":\"kimchy\"," +
            "\"postDate\":\"2013-01-30\"," +
            "\"message\":\"trying out Elasticsearch\"" +
        "}";
HttpEntity entity = new NStringEntity(jsonString, ContentType.APPLICATION_JSON);
Response response = restClient.performRequest("PUT", "/posts/doc/1", params, entity); 

But I would like to know how to perform POST where I don't want to provide the id .

Please assist me with any docs or links.

Thanks.


(David Pilato) #2

Would that work?

Response response = restClient.performRequest("POST", "/posts/doc", params, entity);

(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.