mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-29 15:22:11 +00:00
parent
b038bbe778
commit
8a1d8deb67
@ -60,6 +60,7 @@ import org.springframework.data.util.Streamable;
|
|||||||
import org.springframework.lang.NonNull;
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class contains methods that are common to different implementations of the {@link ElasticsearchOperations}
|
* This class contains methods that are common to different implementations of the {@link ElasticsearchOperations}
|
||||||
@ -468,18 +469,20 @@ public abstract class AbstractElasticsearchTemplate implements ElasticsearchOper
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected <T> UpdateQuery buildUpdateQueryByEntity(T entity) {
|
protected <T> UpdateQuery buildUpdateQueryByEntity(T entity) {
|
||||||
|
|
||||||
Assert.notNull(entity, "entity must not be null");
|
Assert.notNull(entity, "entity must not be null");
|
||||||
|
|
||||||
String id = getEntityId(entity);
|
String id = getEntityId(entity);
|
||||||
Assert.notNull(entity, "entity must have an id that is notnull");
|
Assert.notNull(id, "entity must have an id that is notnull");
|
||||||
|
|
||||||
UpdateQuery.Builder updateQueryBuilder = UpdateQuery.builder(id)
|
UpdateQuery.Builder updateQueryBuilder = UpdateQuery.builder(id)
|
||||||
.withDocument(elasticsearchConverter.mapObject(entity));
|
.withDocument(elasticsearchConverter.mapObject(entity));
|
||||||
|
|
||||||
String routing = getEntityRouting(entity);
|
String routing = getEntityRouting(entity);
|
||||||
if (Objects.nonNull(routing)) {
|
if (StringUtils.hasText(routing)) {
|
||||||
updateQueryBuilder.withRouting(routing);
|
updateQueryBuilder.withRouting(routing);
|
||||||
}
|
}
|
||||||
|
|
||||||
return updateQueryBuilder.build();
|
return updateQueryBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ import org.springframework.data.elasticsearch.core.query.UpdateQuery;
|
|||||||
import org.springframework.data.elasticsearch.core.query.UpdateResponse;
|
import org.springframework.data.elasticsearch.core.query.UpdateResponse;
|
||||||
import org.springframework.data.elasticsearch.core.reindex.ReindexRequest;
|
import org.springframework.data.elasticsearch.core.reindex.ReindexRequest;
|
||||||
import org.springframework.data.elasticsearch.core.reindex.ReindexResponse;
|
import org.springframework.data.elasticsearch.core.reindex.ReindexResponse;
|
||||||
import org.springframework.data.elasticsearch.core.routing.RoutingResolver;
|
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -297,9 +296,10 @@ public interface DocumentOperations {
|
|||||||
/**
|
/**
|
||||||
* Partially update a document by the given entity.
|
* Partially update a document by the given entity.
|
||||||
*
|
*
|
||||||
* @param entity the entity to update partially
|
* @param entity the entity to update partially, must not be {@literal null}.
|
||||||
* @return the update response
|
* @return the update response
|
||||||
* @param <T> the entity type
|
* @param <T> the entity type
|
||||||
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
<T> UpdateResponse update(T entity);
|
<T> UpdateResponse update(T entity);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user