mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-01 09:42:11 +00:00
DATAES-908 - Polishing.
This commit is contained in:
parent
c82792b34d
commit
26ab5f6db4
@ -148,9 +148,8 @@ public class ElasticsearchRestTemplate extends AbstractElasticsearchTemplate {
|
||||
// We should call this because we are not going through a mapper.
|
||||
Object queryObject = query.getObject();
|
||||
if (queryObject != null) {
|
||||
updateIndexedObject(queryObject,
|
||||
IndexedObjectInformation.of(indexResponse.getId(), indexResponse.getSeqNo(),
|
||||
indexResponse.getPrimaryTerm(), indexResponse.getVersion()));
|
||||
updateIndexedObject(queryObject, IndexedObjectInformation.of(indexResponse.getId(), indexResponse.getSeqNo(),
|
||||
indexResponse.getPrimaryTerm(), indexResponse.getVersion()));
|
||||
}
|
||||
|
||||
maybeCallbackAfterSaveWithQuery(query, index);
|
||||
|
@ -162,9 +162,8 @@ public class ElasticsearchTemplate extends AbstractElasticsearchTemplate {
|
||||
// We should call this because we are not going through a mapper.
|
||||
Object queryObject = query.getObject();
|
||||
if (queryObject != null) {
|
||||
updateIndexedObject(queryObject,
|
||||
IndexedObjectInformation.of(documentId, response.getSeqNo(), response.getPrimaryTerm(),
|
||||
response.getVersion()));
|
||||
updateIndexedObject(queryObject, IndexedObjectInformation.of(documentId, response.getSeqNo(),
|
||||
response.getPrimaryTerm(), response.getVersion()));
|
||||
}
|
||||
|
||||
maybeCallbackAfterSaveWithQuery(query, index);
|
||||
|
@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.core;
|
||||
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.springframework.data.mapping.PersistentPropertyAccessor;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.util.function.Tuple2;
|
||||
@ -27,6 +25,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.bulk.BulkItemResponse;
|
||||
import org.elasticsearch.action.bulk.BulkRequest;
|
||||
import org.elasticsearch.action.bulk.BulkResponse;
|
||||
@ -75,6 +74,7 @@ import org.springframework.data.elasticsearch.core.query.Query;
|
||||
import org.springframework.data.elasticsearch.core.query.SeqNoPrimaryTerm;
|
||||
import org.springframework.data.elasticsearch.core.query.UpdateQuery;
|
||||
import org.springframework.data.elasticsearch.support.VersionInfo;
|
||||
import org.springframework.data.mapping.PersistentPropertyAccessor;
|
||||
import org.springframework.data.mapping.callback.ReactiveEntityCallbacks;
|
||||
import org.springframework.data.mapping.context.MappingContext;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@ -206,9 +206,8 @@ public class ReactiveElasticsearchTemplate implements ReactiveElasticsearchOpera
|
||||
.map(it -> {
|
||||
T savedEntity = it.getT1();
|
||||
IndexResponse indexResponse = it.getT2();
|
||||
return updateIndexedObject(savedEntity,
|
||||
IndexedObjectInformation.of(indexResponse.getId(), indexResponse.getSeqNo(),
|
||||
indexResponse.getPrimaryTerm(), indexResponse.getVersion()));
|
||||
return updateIndexedObject(savedEntity, IndexedObjectInformation.of(indexResponse.getId(),
|
||||
indexResponse.getSeqNo(), indexResponse.getPrimaryTerm(), indexResponse.getVersion()));
|
||||
}).flatMap(saved -> maybeCallAfterSave(saved, index));
|
||||
}
|
||||
|
||||
@ -244,9 +243,8 @@ public class ReactiveElasticsearchTemplate implements ReactiveElasticsearchOpera
|
||||
BulkItemResponse bulkItemResponse = indexAndResponse.getT2();
|
||||
|
||||
DocWriteResponse response = bulkItemResponse.getResponse();
|
||||
updateIndexedObject(savedEntity,
|
||||
IndexedObjectInformation.of(response.getId(), response.getSeqNo(),
|
||||
response.getPrimaryTerm(), response.getVersion()));
|
||||
updateIndexedObject(savedEntity, IndexedObjectInformation.of(response.getId(), response.getSeqNo(),
|
||||
response.getPrimaryTerm(), response.getVersion()));
|
||||
|
||||
return maybeCallAfterSave(savedEntity, index);
|
||||
});
|
||||
|
@ -3469,10 +3469,10 @@ public abstract class ElasticsearchTemplateTests {
|
||||
|
||||
@Test // DATAES-908
|
||||
void shouldFillVersionOnSaveArray() {
|
||||
VersionedEntity[] array = {new VersionedEntity(), new VersionedEntity()};
|
||||
VersionedEntity[] array = { new VersionedEntity(), new VersionedEntity() };
|
||||
Iterator<VersionedEntity> results = operations.save(array).iterator();
|
||||
VersionedEntity saved1 = results.next();
|
||||
VersionedEntity saved2= results.next();
|
||||
VersionedEntity saved2 = results.next();
|
||||
|
||||
assertThat(saved1.getVersion()).isNotNull();
|
||||
assertThat(saved2.getVersion()).isNotNull();
|
||||
@ -3490,7 +3490,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
@Test // DATAES-908
|
||||
void shouldFillVersionOnBulkIndex() {
|
||||
VersionedEntity entity1 = new VersionedEntity();
|
||||
VersionedEntity entity2= new VersionedEntity();
|
||||
VersionedEntity entity2 = new VersionedEntity();
|
||||
IndexQuery query1 = new IndexQueryBuilder().withObject(entity1).build();
|
||||
IndexQuery query2 = new IndexQueryBuilder().withObject(entity2).build();
|
||||
operations.bulkIndex(Arrays.asList(query1, query2), VersionedEntity.class);
|
||||
|
@ -974,8 +974,7 @@ public class ReactiveElasticsearchTemplateTests {
|
||||
|
||||
@Test // DATAES-908
|
||||
void shouldFillVersionOnSaveAll() {
|
||||
VersionedEntity saved = template.saveAll(singletonList(new VersionedEntity()), VersionedEntity.class)
|
||||
.blockLast();
|
||||
VersionedEntity saved = template.saveAll(singletonList(new VersionedEntity()), VersionedEntity.class).blockLast();
|
||||
|
||||
assertThat(saved.getVersion()).isNotNull();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user