Skip to content

Commit c45ff27

Browse files
lipsillnik9000
authored andcommitted
Deprecate _source_include and _source_exclude url parameters (#33475)
Deprecates `_source_include` and `_source_exclude` url parameters in favor of `_source_inclues` and `_source_excludes` because those are consistent with the rest of Elasticsearch's APIs. Relates to #22792
1 parent 547a16d commit c45ff27

File tree

25 files changed

+123
-59
lines changed

25 files changed

+123
-59
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,10 +747,10 @@ Params withFetchSourceContext(FetchSourceContext fetchSourceContext) {
747747
putParam("_source", Boolean.FALSE.toString());
748748
}
749749
if (fetchSourceContext.includes() != null && fetchSourceContext.includes().length > 0) {
750-
putParam("_source_include", String.join(",", fetchSourceContext.includes()));
750+
putParam("_source_includes", String.join(",", fetchSourceContext.includes()));
751751
}
752752
if (fetchSourceContext.excludes() != null && fetchSourceContext.excludes().length > 0) {
753-
putParam("_source_exclude", String.join(",", fetchSourceContext.excludes()));
753+
putParam("_source_excludes", String.join(",", fetchSourceContext.excludes()));
754754
}
755755
}
756756
return this;

client/rest-high-level/src/test/java/org/elasticsearch/client/RequestConvertersTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,13 +1589,13 @@ private static void randomizeFetchSourceContextParams(Consumer<FetchSourceContex
15891589
String[] includes = new String[numIncludes];
15901590
String includesParam = randomFields(includes);
15911591
if (numIncludes > 0) {
1592-
expectedParams.put("_source_include", includesParam);
1592+
expectedParams.put("_source_includes", includesParam);
15931593
}
15941594
int numExcludes = randomIntBetween(0, 5);
15951595
String[] excludes = new String[numExcludes];
15961596
String excludesParam = randomFields(excludes);
15971597
if (numExcludes > 0) {
1598-
expectedParams.put("_source_exclude", excludesParam);
1598+
expectedParams.put("_source_excludes", excludesParam);
15991599
}
16001600
consumer.accept(new FetchSourceContext(true, includes, excludes));
16011601
}

docs/reference/docs/get.asciidoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ GET twitter/_doc/0?_source=false
7373
// CONSOLE
7474
// TEST[setup:twitter]
7575

76-
If you only need one or two fields from the complete `_source`, you can use the `_source_include`
77-
& `_source_exclude` parameters to include or filter out that parts you need. This can be especially helpful
76+
If you only need one or two fields from the complete `_source`, you can use the `_source_includes`
77+
& `_source_excludes` parameters to include or filter out that parts you need. This can be especially helpful
7878
with large documents where partial retrieval can save on network overhead. Both parameters take a comma separated list
7979
of fields or wildcard expressions. Example:
8080

8181
[source,js]
8282
--------------------------------------------------
83-
GET twitter/_doc/0?_source_include=*.id&_source_exclude=entities
83+
GET twitter/_doc/0?_source_includes=*.id&_source_excludes=entities
8484
--------------------------------------------------
8585
// CONSOLE
8686
// TEST[setup:twitter]
@@ -232,7 +232,7 @@ You can also use the same source filtering parameters to control which parts of
232232

233233
[source,js]
234234
--------------------------------------------------
235-
GET twitter/_doc/1/_source?_source_include=*.id&_source_exclude=entities'
235+
GET twitter/_doc/1/_source?_source_includes=*.id&_source_excludes=entities'
236236
--------------------------------------------------
237237
// CONSOLE
238238
// TEST[continued]

docs/reference/docs/multi-get.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ GET /test/_doc/_mget
8989
By default, the `_source` field will be returned for every document (if stored).
9090
Similar to the <<get-source-filtering,get>> API, you can retrieve only parts of
9191
the `_source` (or not at all) by using the `_source` parameter. You can also use
92-
the url parameters `_source`,`_source_include` & `_source_exclude` to specify defaults,
92+
the url parameters `_source`,`_source_includes` & `_source_excludes` to specify defaults,
9393
which will be used when there are no per-document instructions.
9494

9595
For example:

docs/reference/migration/migrate_6_6.asciidoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,12 @@ Using automatically expanded fields for the "all fields" mode ("default_field":
2222
for the `query_string`, `multi_match` and `simple_query_string` now raises a warning and
2323
a deprecation notice to be logged for queries beyond 1024 fields. This limit will be
2424
enforced with a hard error starting in 7.0.
25+
26+
[float]
27+
==== Deprecate `_source_exclude` and `_source_include` URL Parameters
28+
29+
`_source_exclude` and `_source_include` are deprecated in favor of
30+
`_source_excludes` and `_source_includes` because those line up better with the
31+
rest of Elasticsearc's APIs and Elasticsearch will raise a deprecation warning
32+
if those are used on any APIs. We plan to drop support for `_source_exclude` and
33+
`_source_include` in 7.0.

docs/reference/search/explain.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ This will yield the same result as the previous request.
117117
`_source`::
118118

119119
Set to `true` to retrieve the `_source` of the document explained. You can also
120-
retrieve part of the document by using `_source_include` & `_source_exclude` (see <<get-source-filtering,Get API>> for more details)
120+
retrieve part of the document by using `_source_includes` & `_source_excludes` (see <<get-source-filtering,Get API>> for more details)
121121

122122
`stored_fields`::
123123
Allows to control which stored fields to return as part of the

docs/reference/search/uri-request.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ providing text to a numeric field) to be ignored. Defaults to false.
8383
hits was computed.
8484

8585
|`_source`|Set to `false` to disable retrieval of the `_source` field. You can also retrieve
86-
part of the document by using `_source_include` & `_source_exclude` (see the <<search-request-source-filtering, request body>>
86+
part of the document by using `_source_includes` & `_source_excludes` (see the <<search-request-source-filtering, request body>>
8787
documentation for more details)
8888

8989
|`stored_fields` |The selective stored fields of the document to return for each hit,

rest-api-spec/src/main/resources/rest-api-spec/api/bulk.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@
4545
"type" : "list",
4646
"description" : "True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request"
4747
},
48-
"_source_exclude": {
48+
"_source_excludes": {
4949
"type" : "list",
5050
"description" : "Default list of fields to exclude from the returned _source field, can be overridden on each sub-request"
5151
},
52-
"_source_include": {
52+
"_source_includes": {
5353
"type" : "list",
5454
"description" : "Default list of fields to extract and return from the _source field, can be overridden on each sub-request"
5555
},

rest-api-spec/src/main/resources/rest-api-spec/api/delete_by_query.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@
102102
"type" : "list",
103103
"description" : "True or false to return the _source field or not, or a list of fields to return"
104104
},
105-
"_source_exclude": {
105+
"_source_excludes": {
106106
"type" : "list",
107107
"description" : "A list of fields to exclude from the returned _source field"
108108
},
109-
"_source_include": {
109+
"_source_includes": {
110110
"type" : "list",
111111
"description" : "A list of fields to extract and return from the _source field"
112112
},

rest-api-spec/src/main/resources/rest-api-spec/api/exists.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@
5151
"type" : "list",
5252
"description" : "True or false to return the _source field or not, or a list of fields to return"
5353
},
54-
"_source_exclude": {
54+
"_source_excludes": {
5555
"type" : "list",
5656
"description" : "A list of fields to exclude from the returned _source field"
5757
},
58-
"_source_include": {
58+
"_source_includes": {
5959
"type" : "list",
6060
"description" : "A list of fields to extract and return from the _source field"
6161
},

0 commit comments

Comments
 (0)