nest : how use UpdateByQuery()?

廉价感情. 提交于 2019-12-14 02:36:22

问题


I would like to use the UpdateByQuery() methode

If i understood well i need to give a query and a select.

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

Could you help me please?


回答1:


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)));

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().



来源:https://stackoverflow.com/questions/42210930/nest-how-use-updatebyquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!