Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,9 @@ public DeleteByQueryRequest documentDeleteByQueryRequest(DeleteQuery query, @Nul
.collect(Collectors.toList()));
}
}
if (query.getRefresh() != null) {
dqb.refresh(query.getRefresh());
}
dqb.allowNoIndices(query.getAllowNoIndices())
.conflicts(conflicts(query.getConflicts()))
.ignoreUnavailable(query.getIgnoreUnavailable())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@
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 {

Expand Down Expand Up @@ -72,6 +76,19 @@ void shouldAddDocvalueFields() {
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
Expand Down