IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Fields Usage
edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.
Fields Usage
editAllows to selectively load specific stored fields for each document represented by a search hit.
The fields
parameter is about fields that are explicitly marked as stored in the mapping,
which is off by default and generally not recommended.
Use source filtering instead to select subsets of the original source document to be returned.
See the Elasticsearch documentation on Fields for more detail.
Fluent DSL example
edits => s .Query(q => ProjectFilter) .StoredFields(fs => fs .Field(p => p.Name) .Field(p => p.StartedOn) .Field(p => p.NumberOfCommits) .Field(p => p.NumberOfContributors) .Field(p => p.DateString) )
Object Initializer syntax example
editnew SearchRequest<Project> { Query = ProjectFilter, StoredFields = Fields<Project>( p => p.Name, p => p.StartedOn, p => p.NumberOfCommits, p => p.NumberOfContributors, p => p.DateString) }
Example json output.
{ "query": { "term": { "type": { "value": "project" } } }, "stored_fields": [ "name", "startedOn", "numberOfCommits", "numberOfContributors", "dateString" ] }