You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
@OverridepublicStringindex(IndexQueryquery) {
StringdocumentId = 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);
}
returndocumentId;
}
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
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:No further details from DATAES-229
The text was updated successfully, but these errors were encountered: