因此,借助CURL api的工作原理,我设法提出了一种方法。
首先,您需要编辑您的
elasticsearch.yml脚本以允许脚本。最后添加以下几行。
script.engine.groovy.inline.search: onscript.engine.groovy.inline.aggs: onscript.engine.groovy.inline.update: on
之后,您可以开始使用查询作为下面的示例进行批处理更新。
$client = ElasticsearchClientBuilder::create()->setHosts(['127.0.0.1:9200'])->build(); # Request $updateRequest = [ 'index' => 'testindex', 'type' => 'logs', 'conflicts' => 'proceed', 'body' => [ 'query' => [ 'filtered' => [ 'filter' => [ 'bool' => [ 'must' => [[ 'match' => [ 'enabled' => 1 ],], ] ] ] ] ], 'script' => [ 'inline' => 'ctx._source.enabled = value', 'params' => [ 'value' => 0 ] ] ] ] ]; # Update $results = $client->updateByQuery($updateRequest);
而已。到目前为止,它并不容易且没有很好的文档记录。



