What error is it throwing? Can you include the test.DebugInformation?
It looks like you're want to update a single document, based on the term query on _id. For this, you can use a scripted update with the Update API (looks like you're using NEST 6.x?)
var id = 1;
var name = "updated_name";
var test = client.Update<object>(id, u => u
.Index("test")
.Type("doc")
.Script(s => s
.Source("ctx._source.name = params.name")
.Params(p => p
.Add("name", name)
)
)
.Refresh(Refresh.True)
);
for an Update where you are simply overwriting a field value though, you can supply a partial document to do this. A partial document can be modelled with an anonymous type
var id = 1;
var name = "updated_name";
var test = client.Update<object>(id, u => u
.Index("test")
.Type("doc")
.Doc(new
{
name = name
})
.Refresh(Refresh.True)
);
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.