Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete by query to not wrap the inner query into an additional query element #14302

Merged
merged 1 commit into from Oct 27, 2015
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -107,8 +107,8 @@ void executeScan() {
scanRequest.routing(request.routing());
}

scanRequest.source(request.source());
SearchSourceBuilder source = new SearchSourceBuilder()
.query(request.source())
.fields("_routing", "_parent")
.sort("_doc") // important for performance
.fetchSource(false)
Expand All @@ -119,7 +119,7 @@ void executeScan() {
if (request.timeout() != null) {
source.timeout(request.timeout());
}
scanRequest.source(source);
scanRequest.extraSource(source);

logger.trace("executing scan request");
searchAction.execute(scanRequest, new ActionListener<SearchResponse>() {
Expand Down Expand Up @@ -302,10 +302,6 @@ boolean hasTimedOut() {
return request.timeout() != null && (threadPool.estimatedTimeInMillis() >= (startTime + request.timeout().millis()));
}

void addShardFailure(ShardOperationFailedException failure) {
addShardFailures(new ShardOperationFailedException[]{failure});
}

void addShardFailures(ShardOperationFailedException[] failures) {
if (!CollectionUtils.isEmpty(failures)) {
ShardOperationFailedException[] duplicates = new ShardOperationFailedException[shardFailures.length + failures.length];
Expand Down
Expand Up @@ -30,6 +30,7 @@
import org.elasticsearch.action.search.ClearScrollResponse;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.action.support.QuerySourceBuilder;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.text.StringText;
import org.elasticsearch.common.unit.TimeValue;
Expand Down Expand Up @@ -85,7 +86,7 @@ public void testExecuteScan() {
assertHitCount(client().prepareCount("test").get(), numDocs);

final long limit = randomIntBetween(0, numDocs);
DeleteByQueryRequest delete = new DeleteByQueryRequest().indices("test").source(boolQuery().must(rangeQuery("num").lte(limit)).buildAsBytes());
DeleteByQueryRequest delete = new DeleteByQueryRequest().indices("test").source(new QuerySourceBuilder().setQuery(boolQuery().must(rangeQuery("num").lte(limit))));
TestActionListener listener = new TestActionListener();

newAsyncAction(delete, listener).executeScan();
Expand Down
@@ -1,5 +1,4 @@
---
"Basic delete_by_query":
setup:
- do:
index:
index: test_1
Expand All @@ -24,6 +23,8 @@
- do:
indices.refresh: {}

---
"Basic delete_by_query":
- do:
delete_by_query:
index: test_1
Expand All @@ -40,3 +41,14 @@
index: test_1

- match: { count: 2 }

---
"No query element delete_by_query":
- do:
catch: request
delete_by_query:
index: test_1
body:
match:
foo: bar