- .NET Clients: other versions:
- Introduction
- Building
- Breaking Changes
- Elasticsearch.Net
- NEST
- Core
- Indices
- Cluster
- Search
- Aggregations
- Handling Aggregations
- Avg aggregation
- Cardinality aggregation
- Date Histogram aggregation
- Date Range aggregation
- Extended Stats Aggregation
- Filter aggregation
- Geo Distance aggregation
- Geohash Grid aggregation
- Global aggregation
- Histogram aggregation
- IPv4 Range aggregation
- Max aggregation
- Min aggregation
- Missing aggregation
- Percentiles aggregation
- Percentile Ranks aggregation
- Range aggregation
- Nested aggregation
- Reverse Nested aggregation
- Significant Terms aggregation
- Stats aggregation
- Sum aggregation
- Terms aggregation
- Top Hits aggregation
- Value Count aggregation
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.
Indexing
editIndexing
editIndexing is as simple as:
var post = new Post() { Id = 12, ... } var status = client.Index<Post>(post);
Of course C# is smart enough to infer Post
so
var status = client.Index(post);
is sufficient. This will index post
to /[default index]/posts/12
. The type name posts
is automatically inferred from the type.
If you need more control, there are plenty of overloads, i.e:
client.Index(post, i => i .Index(index) .Type(type) .Id(post.Id) );
You can also construct the index request using the object initializer syntax instead:
var request = new IndexRequest<Post> { Index = index, Type = type, Id = post.Id }; client.Index<Post>(post);
Asynchronous
editIndexing asynchronously is as easy as:
var task = client.IndexAsync(post); // IndexAsync returns a Task<ConnectionStatus>
Bulk Indexing
editSee the section dedicated to using the bulk api for details on how to construct bulk indexing requests.
On this page