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.