Skip to content
ElasticSearch .NET Client
Find file
New pull request
Pull request Compare This branch is 3 commits ahead, 2803 commits behind elastic:master.
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Strongly typed Elasticsearch client

NEST aims to be a .net client with a very concise API.


Basic plumbing:

var elasticSettings = new ConnectionSettings("", 9200)
var client = new ElasticClient(elasticSettings);

Connecting can be done several ways:

ConnectionStatus connectionStatus;
if (!client.TryConnect(out connectionStatus))

Or if you don't care about error reasons

if (client.IsValid)


Indexing is as simple as:

var post = new Post() { Id = 12, ... }

of course C# is smart enough to infer Post so


is sufficient. this will index post too /[default index]/posts/12. 'posts is inferred from the type.

if you need more control there are plenty of overloads, i.e:


Indexing asynchronously is as easy as:

client.IndexAsync(post, (c) => /* called later */);

or just:


Bulk indexing

Instead of passing T just pass IEnumerable<T> for both Index or IndexAsync. A zero copy approach that writes directly on the post stream is planned in a later version.

Note For asynchronous commands there's a special connection setting which automatically semaphores threaded communication to ES for you:

var elasticSettings = new ConnectionSettings("", 9200)

this ensures that at most there are 20 asynchronous connections to ES others are enqueued until a slot is available.

Query DSL

This part is still evolving but currently looks like this:

QueryResponse<Blog> queryResults = client.Search<Blog>
    new Search()
        Query = new Query(new   Fuzzy("author.firstName", "shay", 1.0))

queryResults.Documents now yields all the blogs found (between 0 and 10 of course).

Something went wrong with that request. Please try again.