WARNING: Version 5.x has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Source Filtering Usage
editSource Filtering Usage
editAllows to control how the _source
field is returned with every hit.
By default operations return the contents of the _source
field unless
you have used the fields parameter or if the _source
field is disabled.
See the Elasticsearch documentation on Source Filtering for more detail.
Fluent DSL example
edits => s .Source(src => src .IncludeAll() .Excludes(e => e .Fields( p => p.Description ) ) )
Object Initializer syntax example
editnew SearchRequest<Project> { Source = new SourceFilter { Includes = "*", Excludes = Fields<Project>(p => p.Description) } }
Example json output.
{ "_source": { "includes": [ "*" ], "excludes": [ "description" ] } }
Handling Responses
editresponse.ShouldBeValid(); foreach (var document in response.Documents) { document.Name.Should().NotBeNull(); document.StartedOn.Should().NotBe(default(DateTime)); document.Description.Should().BeNull(); }
Fluent DSL example
edits => s.Source(false)
Object Initializer syntax example
editnew SearchRequest<Project> { Source = false }
Example json output.
{ "_source": false }
Handling Responses
editresponse.ShouldBeValid(); foreach (var hit in response.Hits) hit.Source.Should().BeNull();