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.
Search
edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.
Search
editSearch is the call you’ll probably use the most, as it exposes Elasticsearch’s key functionality: search!
Fluent DSL
editvar result = client.Search<ElasticsearchProject>(s => s
.From(0)
.Size(50)
.Query(q => ....)
.Filter(f => ....)
);
Object Initializer Syntax
editvar searchRequest = new SearchRequest
{
From = 0,
Size = 50,
Query = ...
Filter = ...
};
var result = client.Search<ElasticsearchProject>(searchRequest);
Handling the Search response
edit.Search<T> returns an ISearchResponse<T> which has a Hits property.
Hits is an IEnumerable<IHit<T>>. IHit<T> contains a Source property which
holds the original document T), along with other meta deta from Elasticsearch such
as Id, Score, Version, Index, Type, Sorts, Highlights and Explanation.
See Search Basics section for more information.