2017-05-11 14 views
1

弾性検索2.3。私は条件に基づいてインデックス内のすべてのドキュメントを更新するためにこのクエリを起動しています。Elasticsearchの条件付き更新: "無効な操作[なし]"

{ 
    "query": { 
    "bool": { 
     "must": [ 
     { 
      "match_all": {} 
     } 
     ] 
    } 
    }, 
    "script": { 
    "inline": "if (ctx._source.url.endsWith('a=6')) ctx.op = 'none' else ctx._source.url = ctx._source.url + '&b=3'" 
    } 
} 

としては、私は条件に一致しないドキュメントの更新を避けるためにctx.op = 'none'を使用しています、here述べました。

私は

Invalid op [none]

全エラーを取得しています:

"error": { 
"root_cause": [ 
{ 
"type": "illegal_argument_exception", 
"reason": "Invalid op [none]" 
} 
], 
"type": "illegal_argument_exception", 
"reason": "Invalid op [none]" 
}, 
"status": 400 

は、私はかなり失われていますようにシンプルであるように思われます。ご協力いただきありがとうございます。

答えて

3

正しい操作は、noopであり、ではありません。 the documentationから

Just as in Update API you can set ctx.op = "noop" if your script decides that it doesn’t have to make any changes. That will cause _update_by_query to omit that document from its updates.

PRを作成しました:https://github.com/elastic/elasticsearch/pull/24613

+0

感謝を。今働いているようだ。したがって、上記2.3のドキュメントは何らかの形で間違っているか、少なくともあいまいです。 – AitorF

+0

ドキュメント自体は問題ありません。例だけが間違っています(古いもの)。 –

関連する問題