Added types options to DeleteByQueryRequest (#23265)

Add types setter and getter to `DeleteByQueryRequest`, which delegate to the inner `SearchRequest`.
This commit is contained in:
Kunal Kapoor 2017-03-02 21:22:21 +05:30 committed by Luca Cavanna
parent 6519e1207c
commit 32d292b3c2
2 changed files with 36 additions and 2 deletions

View File

@ -111,4 +111,16 @@ public class DeleteByQueryRequest extends AbstractBulkByScrollRequest<DeleteByQu
assert getSearchRequest() != null;
return getSearchRequest().indicesOptions();
}
public String[] types() {
assert getSearchRequest() != null;
return getSearchRequest().types();
}
public DeleteByQueryRequest types(String... types) {
assert getSearchRequest() != null;
getSearchRequest().types(types);
return this;
}
}

View File

@ -19,8 +19,6 @@
package org.elasticsearch.action.bulk.byscroll;
import org.elasticsearch.action.bulk.byscroll.AbstractBulkByScrollRequestTestCase;
import org.elasticsearch.action.bulk.byscroll.DeleteByQueryRequest;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.support.IndicesOptions;
@ -74,4 +72,28 @@ public class DeleteByQueryRequestTests extends AbstractBulkByScrollRequestTestCa
protected void extraForSliceAssertions(DeleteByQueryRequest original, DeleteByQueryRequest forSliced) {
// No extra assertions needed
}
public void testTypesGetter() {
int numTypes = between(1, 50);
String[] types = new String[numTypes];
for (int i = 0; i < numTypes; i++) {
types[i] = randomSimpleString(random(), 1, 30);
}
SearchRequest searchRequest = new SearchRequest();
searchRequest.types(types);
DeleteByQueryRequest request = new DeleteByQueryRequest(searchRequest);
assertArrayEquals(request.types(), types);
}
public void testTypesSetter() {
int numTypes = between(1, 50);
String[] types = new String[numTypes];
for (int i = 0; i < numTypes; i++) {
types[i] = randomSimpleString(random(), 1, 30);
}
SearchRequest searchRequest = new SearchRequest();
DeleteByQueryRequest request = new DeleteByQueryRequest(searchRequest);
request.types(types);
assertArrayEquals(request.types(), types);
}
}