-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the ability to disable the retrieval of the stored fields entirely #20026
Conversation
i like the looks of this. One question: what if I want (eg) Or maybe this doesn't matter as the real cost is retrieving stored fields, rather than serialising them (i think?) |
Yes that's the spirit. Don't think we should allow to enable/disable metadata field separately. |
-------------------------------------------------- | ||
GET /_search | ||
{ | ||
"stored_field": "_none_", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be stored_fields
(plural)
+1 to forbid loading anything from stored fields when |
I am a bit on the fence about making the REST and Java APIs diverge (REST only has |
Thanks @jpountz. I pushed another commit to address your comments. |
@jimferenczi It seems that |
Yes sorry about that, this is a leftover. This PR should not touch the GetRequest at all. |
* Sets the fields to load and return as part of the search request. If none | ||
* are specified, the source of the document will be returned. | ||
* Adds stored fields to load and return (note, it must be stored) as part of the search request. | ||
* To disable the stored fields entirely (source and metadata fields) use {@code storedField("_none_")}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/storedField("_none_")/storedFields("_none_")/
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh nevermind I see there is a storedField method too
I left some comments. |
Thanks @jpountz , I pushed a commit to address your comments. |
} | ||
|
||
private StoredFieldsContext(List<String> fieldNames) { | ||
Objects.requireNonNull("fieldNames must not be null"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should pass fieldNames as an argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oups :(
LGTM |
This change adds a special field named _none_ that allows to disable the retrieval of the stored fields in a search request or in a TopHitsAggregation. To completely disable stored fields retrieval (including disabling metadata fields retrieval such as _id or _type) use _none_ like this: ```` POST _search { "stored_fields": "_none_" } ````
Thanks @jpountz ! |
This is a spin off of #19918 (comment)
This change adds a special field named none that allows to disable the retrieval of the stored fields in a search request or in a TopHitsAggregation.
To completely disable stored fields retrieval (including disabling metadata fields retrieval such as _id or _type) use none: