DATAES-56 - while specifying index and type at runtime indexing is failing
(this bug was introduced with DATAES-42)
This commit is contained in:
@@ -547,8 +547,11 @@ public class ElasticsearchTemplate implements ElasticsearchOperations {
|
||||
IndexRequestBuilder indexRequestBuilder = null;
|
||||
|
||||
if (query.getObject() != null) {
|
||||
String entityId = null;
|
||||
if (isDocument(query.getObject().getClass())) {
|
||||
entityId = getPersistentEntityId(query.getObject());
|
||||
}
|
||||
// If we have a query id and a document id, do not ask ES to generate one.
|
||||
String entityId = getPersistentEntityId(query.getObject());
|
||||
if (query.getId() != null && entityId != null) {
|
||||
indexRequestBuilder = client.prepareIndex(indexName, type, query.getId());
|
||||
} else {
|
||||
@@ -685,4 +688,8 @@ public class ElasticsearchTemplate implements ElasticsearchOperations {
|
||||
protected ResultsMapper getResultsMapper() {
|
||||
return resultsMapper;
|
||||
}
|
||||
|
||||
private boolean isDocument(Class clazz) {
|
||||
return clazz.isAnnotationPresent(Document.class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user