I have ported my code to NEST 2.0 and Elasticsearch 2.0
I need to find a way to update a document already stored into ES2
I was using the partial object technique:
elastic.Update<myDocumentType, myPartialDocumentType>(u => u
.Index(myIndexName)
.Id(id)
.Doc(
new myPartialDocumentType()
{
// set the fields to update here
})
.Refresh());
How to do the same thing using NEST2?
The way how you are passing document id changed a bit.
Looks like follow today:
var updateResponse = client.Update<Document, DocumentPartial>(1, descriptor => descriptor
.Doc(new DocumentPartial
{
Title = "new title"
}));
or
var updateResponse = client.Update<Document, DocumentPartial>(DocumentPath<Document>.Id(1), descriptor => descriptor
.Doc(new DocumentPartial
{
Title = "new title"
}));
Hope it helps.
来源:https://stackoverflow.com/questions/35630189/how-to-update-an-elasticsearch-document-in-nest2