Skip to content

Commit

Permalink
Updated Get API to add _source_include_vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikep86 committed Sep 23, 2024
1 parent bef691c commit 07bca98
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions rest-api-spec/src/main/resources/rest-api-spec/api/get.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
"type":"list",
"description":"A list of fields to extract and return from the _source field"
},
"_source_include_vectors": {
"type":"boolean",
"description":"True or false to include vector fields in _source"
},
"version":{
"type":"number",
"description":"Explicit version number for concurrency control"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public static FetchSourceContext parseFromRestRequest(RestRequest request) {
Boolean fetchSource = null;
String[] sourceExcludes = null;
String[] sourceIncludes = null;
Boolean includeVectors = null;

String source = request.param("_source");
if (source != null) {
Expand All @@ -221,8 +222,13 @@ public static FetchSourceContext parseFromRestRequest(RestRequest request) {
sourceExcludes = Strings.splitStringByCommaToArray(sExcludes);
}

if (fetchSource != null || sourceIncludes != null || sourceExcludes != null) {
return FetchSourceContext.of(fetchSource == null || fetchSource, sourceIncludes, sourceExcludes);
String sIncludeVectors = request.param("_source_include_vectors");
if (sIncludeVectors != null) {
includeVectors = Booleans.parseBoolean(sIncludeVectors);
}

if (fetchSource != null || sourceIncludes != null || sourceExcludes != null || includeVectors != null) {
return FetchSourceContext.of(fetchSource == null || fetchSource, sourceIncludes, sourceExcludes, includeVectors);
}
return null;
}
Expand Down

0 comments on commit 07bca98

Please sign in to comment.