nest:如何使用UpdateByQuery()? [英] nest : how use UpdateByQuery()?
问题描述
我想使用UpdateByQuery()方法
I would like to use the UpdateByQuery() methode
如果我很好理解,我需要进行查询和选择.
If i understood well i need to give a query and a select.
例如,我想在proj类中将name属性更改为"welcome"
for example i would like to change the name property to "welcome" in my proj class
我开始写我的方法,但是之后我不知道该怎么办?
I start to write my methode but i don't know what to do after that?
client.UpdateByQuery<proj>(q => q.Query(rq => rq.Term(f => f.idProjet, projetEntity.IdProjet)));
我在智能帮助器中看不到更新流利的方法
I don't see Update fluent methode in the intellisense helper
你能帮我吗?
推荐答案
您需要使用Script
方法.这个例子应该可以工作:
You need to use the Script
method. This example should work:
var scriptParams = new Dictionary<string, object> {{"newName", "welcome"}};
client.UpdateByQuery<proj>(q => q
.Query(rq => rq.Term(f => f.idProjet, projetEntity.IdProjet))
.Script(script => script
.Inline("ctx._source.name = newName;")
.Params(scriptParams)));
要运行此示例,您必须设置elasticsearch.yml中的> script.inline:true .为避免这种情况,您必须使用File()
方法而不是Inline()
.
To run this example you have to set script.inline: true in elasticsearch.yml
. To avoid this you have to use File()
method instead of Inline()
.
这篇关于nest:如何使用UpdateByQuery()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!