Skip to content

Commit 6df1c9e

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 42b4f23 commit 6df1c9e

File tree

26 files changed

+118
-63
lines changed

26 files changed

+118
-63
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
@@ -705,10 +705,10 @@ Params withFetchSourceContext(FetchSourceContext fetchSourceContext) {
705705
putParam("_source", Boolean.FALSE.toString());
706706
}
707707
if (fetchSourceContext.includes() != null && fetchSourceContext.includes().length > 0) {
708-
putParam("_source_include", String.join(",", fetchSourceContext.includes()));
708+
putParam("_source_includes", String.join(",", fetchSourceContext.includes()));
709709
}
710710
if (fetchSourceContext.excludes() != null && fetchSourceContext.excludes().length > 0) {
711-
putParam("_source_exclude", String.join(",", fetchSourceContext.excludes()));
711+
putParam("_source_excludes", String.join(",", fetchSourceContext.excludes()));
712712
}
713713
}
714714
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
@@ -1514,13 +1514,13 @@ private static void randomizeFetchSourceContextParams(Consumer<FetchSourceContex
15141514
String[] includes = new String[numIncludes];
15151515
String includesParam = randomFields(includes);
15161516
if (numIncludes > 0) {
1517-
expectedParams.put("_source_include", includesParam);
1517+
expectedParams.put("_source_includes", includesParam);
15181518
}
15191519
int numExcludes = randomIntBetween(0, 5);
15201520
String[] excludes = new String[numExcludes];
15211521
String excludesParam = randomFields(excludes);
15221522
if (numExcludes > 0) {
1523-
expectedParams.put("_source_exclude", excludesParam);
1523+
expectedParams.put("_source_excludes", excludesParam);
15241524
}
15251525
consumer.accept(new FetchSourceContext(true, includes, excludes));
15261526
}

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/search/explain.asciidoc

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

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

127127
`stored_fields`::
128128
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
},

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

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

0 commit comments

Comments
 (0)