1

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?

Pipo
  • 5,170
  • 7
  • 33
  • 66

1 Answers1

2

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

core
  • 851
  • 1
  • 8
  • 28
  • Thank you for answere. Must I use a script as a string? Is there a way to use an intellisens? – Pipo Feb 14 '17 at 09:23
  • Not that I know. Scripts are very powerful and using different languages. I cannot imagine how to handle foreach loops for example. And furthermore: using inline scripts is not the preferred way because of security issues. Files are the supposed way to use it. – core Feb 14 '17 at 10:33