Skip to content

Commit a379d62

Browse files
authored
Merge pull request #18992 from jimferenczi/fields_rename
Rename `fields` to `stored_fields` and add `docvalue_fields`
2 parents b0da471 + 2f46f53 commit a379d62

File tree

45 files changed

+447
-312
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+447
-312
lines changed

core/src/main/java/org/elasticsearch/action/search/SearchRequestBuilder.java

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ public SearchRequestBuilder setStats(List<String> statsGroups) {
253253
/**
254254
* Sets no fields to be loaded, resulting in only id and type to be returned per field.
255255
*/
256-
public SearchRequestBuilder setNoFields() {
257-
sourceBuilder().noFields();
256+
public SearchRequestBuilder setNoStoredFields() {
257+
sourceBuilder().noStoredFields();
258258
return this;
259259
}
260260

@@ -290,13 +290,23 @@ public SearchRequestBuilder setFetchSource(@Nullable String[] includes, @Nullabl
290290
return this;
291291
}
292292

293+
/**
294+
* Adds a docvalue based field to load and return. The field does not have to be stored,
295+
* but its recommended to use non analyzed or numeric fields.
296+
*
297+
* @param name The field to get from the docvalue
298+
*/
299+
public SearchRequestBuilder addDocValueField(String name) {
300+
sourceBuilder().docValueField(name);
301+
return this;
302+
}
293303

294304
/**
295-
* Adds a field to load and return (note, it must be stored) as part of the search request.
305+
* Adds a stored field to load and return (note, it must be stored) as part of the search request.
296306
* If none are specified, the source of the document will be return.
297307
*/
298-
public SearchRequestBuilder addField(String field) {
299-
sourceBuilder().field(field);
308+
public SearchRequestBuilder addStoredField(String field) {
309+
sourceBuilder().storedField(field);
300310
return this;
301311
}
302312

@@ -305,12 +315,15 @@ public SearchRequestBuilder addField(String field) {
305315
* but its recommended to use non analyzed or numeric fields.
306316
*
307317
* @param name The field to get from the field data cache
318+
* @deprecated Use {@link SearchRequestBuilder#addDocValueField(String)} instead.
308319
*/
320+
@Deprecated
309321
public SearchRequestBuilder addFieldDataField(String name) {
310-
sourceBuilder().fieldDataField(name);
322+
sourceBuilder().docValueField(name);
311323
return this;
312324
}
313325

326+
314327
/**
315328
* Adds a script based field to load and return. The field does not have to be stored,
316329
* but its recommended to use non analyzed or numeric fields.
@@ -368,11 +381,23 @@ public SearchRequestBuilder setTrackScores(boolean trackScores) {
368381
}
369382

370383
/**
371-
* Sets the fields to load and return as part of the search request. If none
384+
* Sets the stored fields to load and return as part of the search request. If none
372385
* are specified, the source of the document will be returned.
386+
*
387+
* @deprecated Use {@link SearchRequestBuilder#storedFields(String...)} instead.
373388
*/
389+
@Deprecated
374390
public SearchRequestBuilder fields(String... fields) {
375-
sourceBuilder().fields(Arrays.asList(fields));
391+
sourceBuilder().storedFields(Arrays.asList(fields));
392+
return this;
393+
}
394+
395+
/**
396+
* Sets the fields to load and return as part of the search request. If none
397+
* are specified, the source of the document will be returned.
398+
*/
399+
public SearchRequestBuilder storedFields(String... fields) {
400+
sourceBuilder().storedFields(Arrays.asList(fields));
376401
return this;
377402
}
378403

0 commit comments

Comments
 (0)