Hi,

I am trying to update several documents at the same time using the update 
by query plugin.

The problem seems to be with the script as the query it self returns the 
correct result with no issues. The thing is ES seems to be able to execute 
the script as there are no exceptions in the logs. Yet nothing gets updated.

So here is the document I am indexing:

curl -XPUT 'localhost:9200/users/files/1' -d '
{
    "path" : "path/to/file"
    "size": 200
}'



No here is my update by query request to change the path field from 
'path/to/file' to 'another/path/to/file':

curl -XPOST  'localhost:9200/users/files/_update_by_query' -d ' 
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "path": "path/to/file"
          }
        }]
    }
  },
  "script": "def str = ctx_source.path;\ndef str2 = 
str.replaceAll(\"path/to/file\", 
\"another/path/to/file\");\nctx._source.path = str2;"
}'



And this is what I get:
{
  "ok":true,
  "took":516,
  "total":75,
  "updated":0,
  "indices":[
    {
      "new_index":{}
    }]
}

so the query matched 75 documents but did not update any.
Anyone knows how can I make it work.

**Here is the script in pretty form:

 def str = ctx_source.path;
 def str2 = str.replaceAll("path/to/file", "another/path/to/file");
 ctx._source.path = str2;


-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/225aa66d-53cb-4cd9-bd94-395eb169b10b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to