Search

edit

Search is the call you’ll probably use the most, as it exposes Elasticsearch’s key functionality: search!

Fluent DSL

edit
var result = client.Search<ElasticsearchProject>(s => s
    .From(0)
    .Size(50)
    .Query(q => ....)
    .Filter(f => ....)
);

Object Initializer Syntax

edit
var 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.