Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't update indexed object if it is no persistent entity [DATAES-229] #803

Closed
spring-projects-issues opened this issue Jan 21, 2016 · 0 comments · Fixed by #1673
Closed
Labels
type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link

Jeff Eltgroth opened DATAES-229 and commented

I am writing a Spring-batch job that uses ElasticsearchTemplate.index(IndexQuery) to load items into an index. I specify the index and type names on the IndexQuery, so I would like to avoid adding @Document to my entity class. If I set the IndexQuery object to a bean without the @Document annotation, ElasticsearchTemplate.setPersistentEntityId throws an assertion exception that the object does not contain the @Document annotation. The operation to store the item to Elasticsearch was completely successful as I can query for the record after the index call.

In the case of index, would it be possible to add a check for the @Document annotation before calling setPersistentEntityId? Possibly:

@Override
public String index(IndexQuery query) {
	String documentId = prepareIndex(query).execute().actionGet().getId();
	// We should call this because we are not going through a mapper.
	if (query.getObject() != null && query.getObject().getClass().isAnnotationPresent(Document.class)) {
		setPersistentEntityId(query.getObject(), documentId);
	}
	return documentId;
}

No further details from DATAES-229

@spring-projects-issues spring-projects-issues added the type: enhancement A general enhancement label Dec 31, 2020
@sothawo sothawo changed the title ElasticsearchTemplate.index(IndexQuery) throws exception if object is missing @Document annotation [DATAES-229] Don't update indexed object if it is no persistent entity [DATAES-229] Jan 30, 2021
sothawo added a commit that referenced this issue Jan 30, 2021
@sothawo sothawo added this to the 4.2 M3 (2021.0.0) milestone Jan 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants