mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-24 13:02:10 +00:00
Set refresh on DeleteByQueryRequest by DeleteQuery.
Original Pull Request #2976 Closes #2973 (cherry picked from commit b1b232d354374d4003a1d640e1aec96bf0a6d687)
This commit is contained in:
parent
a179dd0643
commit
3a9a959918
@ -1021,6 +1021,9 @@ class RequestConverter extends AbstractQueryProcessor {
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
if (query.getRefresh() != null) {
|
||||
dqb.refresh(query.getRefresh());
|
||||
}
|
||||
dqb.allowNoIndices(query.getAllowNoIndices())
|
||||
.conflicts(conflicts(query.getConflicts()))
|
||||
.ignoreUnavailable(query.getIgnoreUnavailable())
|
||||
|
@ -30,12 +30,16 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||
import org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;
|
||||
import org.springframework.data.elasticsearch.core.query.Criteria;
|
||||
import org.springframework.data.elasticsearch.core.query.CriteriaQuery;
|
||||
import org.springframework.data.elasticsearch.core.query.DeleteQuery;
|
||||
import org.springframework.data.elasticsearch.core.query.DocValueField;
|
||||
import org.springframework.data.elasticsearch.core.query.StringQuery;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* @author Peter-Josef Meisch
|
||||
* @author Han Seungwoo
|
||||
*/
|
||||
class RequestConverterTest {
|
||||
|
||||
@ -72,6 +76,19 @@ class RequestConverterTest {
|
||||
assertThat(fieldAndFormats.get(1).format()).isEqualTo("format2");
|
||||
}
|
||||
|
||||
@Test // #2973
|
||||
@DisplayName("should set refresh based on deleteRequest")
|
||||
void refreshSetByDeleteRequest() {
|
||||
var query = new CriteriaQuery(new Criteria("text").contains("test"));
|
||||
var deleteQuery = DeleteQuery.builder(query).withRefresh(true).build();
|
||||
|
||||
var deleteByQueryRequest = requestConverter.documentDeleteByQueryRequest(deleteQuery, null, SampleEntity.class,
|
||||
IndexCoordinates.of("foo"),
|
||||
null);
|
||||
|
||||
assertThat(deleteByQueryRequest.refresh()).isTrue();
|
||||
}
|
||||
|
||||
@Document(indexName = "does-not-matter")
|
||||
static class SampleEntity {
|
||||
@Nullable
|
||||
|
Loading…
x
Reference in New Issue
Block a user