0

Assume spring-boot-starter-data-elasticsearch version 2.1.0.RC1.

Take the following, simple implementation for indexing an entity:

IndexQuery indexQuery = new IndexQueryBuilder().withId(entity.getId()).withObject(entity).build();
String id = elasticsearchTemplate.index(indexQuery);

How do I set the OpType.CREATE on this operation, so that I can assure only documents get indexed which don't already exist?

The equivalent REST API request would look like the following:

POST /{index}/{entity id}?op_type=create
{
    "id" : "{entity id}",
    "attribute" : "value"
}

1 Answer 1

1

This is not supported at the moment by Spring Data ES.

There's a open issue that reports exactly that feature, you might want to check it out: https://jira.spring.io/browse/DATAES-247

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

1 Comment

So I guess I have to use the Elasticsearch Java API to achieve that. Thank you.

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.