diff --git a/docs/reference/mapping/fields/source-field.asciidoc b/docs/reference/mapping/fields/source-field.asciidoc index ec40f665c5c..9c509593b61 100644 --- a/docs/reference/mapping/fields/source-field.asciidoc +++ b/docs/reference/mapping/fields/source-field.asciidoc @@ -34,7 +34,8 @@ Users often disable the `_source` field without thinking about the consequences, and then live to regret it. If the `_source` field isn't available then a number of features are not supported: -* The <>. +* The <>, <>, +and <> APIs. * On the fly <>. @@ -133,4 +134,3 @@ GET logs/event/_search <1> These fields will be removed from the stored `_source` field. <2> We can still search on this field, even though it is not in the stored `_source`. - diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractAsyncBulkIndexByScrollAction.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractAsyncBulkIndexByScrollAction.java index 3f39f824009..bbaa498c5e2 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractAsyncBulkIndexByScrollAction.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/AbstractAsyncBulkIndexByScrollAction.java @@ -86,6 +86,9 @@ public abstract class AbstractAsyncBulkIndexByScrollAction< Map scriptCtx = null; for (SearchHit doc : docs) { + if (doc.isSourceEmpty()) { + throw new IllegalArgumentException("[" + doc.index() + "][" + doc.type() + "][" + doc.id() + "] didn't store _source"); + } IndexRequest index = buildIndexRequest(doc); copyMetadata(index, doc); if (script != null) { diff --git a/modules/reindex/src/test/resources/rest-api-spec/test/reindex/20_validation.yaml b/modules/reindex/src/test/resources/rest-api-spec/test/reindex/20_validation.yaml index d3caf929aa0..eed4da1bc55 100644 --- a/modules/reindex/src/test/resources/rest-api-spec/test/reindex/20_validation.yaml +++ b/modules/reindex/src/test/resources/rest-api-spec/test/reindex/20_validation.yaml @@ -157,6 +157,34 @@ requests_per_second: "" body: source: - from: 1 + index: test + dest: + index: dest + +--- +"reindex without source gives useful error message": + - do: + indices.create: + index: test + body: + mappings: + test: + _source: + enabled: false + - do: + index: + index: test + type: test + id: 1 + body: { age: 23 } + - do: + indices.refresh: {} + + - do: + catch: /\[test\]\[test\]\[1\] didn't store _source/ + reindex: + body: + source: + index: test dest: index: dest diff --git a/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/20_validation.yaml b/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/20_validation.yaml index a1780375b8c..091664704ff 100644 --- a/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/20_validation.yaml +++ b/modules/reindex/src/test/resources/rest-api-spec/test/update_by_query/20_validation.yaml @@ -53,3 +53,27 @@ update_by_query: index: test requests_per_second: '' + +--- +"update_by_query without source gives useful error message": + - do: + indices.create: + index: test + body: + mappings: + test: + _source: + enabled: false + - do: + index: + index: test + type: test + id: 1 + body: { age: 23 } + - do: + indices.refresh: {} + + - do: + catch: /\[test\]\[test\]\[1\] didn't store _source/ + update_by_query: + index: test