reindex: Guard against user disabling fields

This commit is contained in:
Nik Everett 2016-04-12 07:32:29 -04:00
parent 0f9804b0e2
commit c2e745bf3b
4 changed files with 29 additions and 0 deletions

View File

@ -87,6 +87,11 @@ public abstract class AbstractAsyncBulkIndexByScrollAction<
for (SearchHit doc : docs) {
if (doc.isSourceEmpty()) {
/*
* Either the document didn't store _source or we didn't fetch it for some reason. Since we don't allow the user to
* change the "fields" part of the search request it is unlikely that we got here because we didn't fetch _source.
* Thus the error message assumes that it wasn't stored.
*/
throw new IllegalArgumentException("[" + doc.index() + "][" + doc.type() + "][" + doc.id() + "] didn't store _source");
}
IndexRequest index = buildIndexRequest(doc);

View File

@ -117,6 +117,9 @@ public abstract class AbstractBulkByScrollRequest<Self extends AbstractBulkByScr
if (searchRequest.source().from() != -1) {
e = addValidationError("from is not supported in this context", e);
}
if (searchRequest.source().fields() != null) {
e = addValidationError("fields is not supported in this context", e);
}
if (maxRetries < 0) {
e = addValidationError("retries cannnot be negative", e);
}

View File

@ -188,3 +188,15 @@
index: test
dest:
index: dest
---
"source fields may not be modified":
- do:
catch: /fields is not supported in this context/
reindex:
body:
source:
index: test
fields: [_id]
dest:
index: dest

View File

@ -77,3 +77,12 @@
catch: /\[test\]\[test\]\[1\] didn't store _source/
update_by_query:
index: test
---
"source fields may not be modified":
- do:
catch: /fields is not supported in this context/
update_by_query:
index: test
body:
fields: [_id]