php - 如何使用php从Elasticsearch批量删除文档

标签 php elasticsearch bigdata

我正在使用以下代码从elasticsearch中删除文档。

public function deleteByQuery(){

    $client = $this->_connectElasticSearchClient();
    $params = [
       'index' => $this->_indexName,
       'type' => $this->_typeName,
       'body' => [
           'query' => [
               'match' => [
                   'brand' => 'apple'
               ]
           ]
       ]
    ];
    $response = $client->deleteByQuery($params);
    print_r($response);die;
 }

我得到以下答复。
{
  "found": false,
  "_index": "gadgets",
  "_type": "products",
  "_id": "_query",
  "_version": 1,
  "_shards": {
    "total": 1,
    "successful": 1,
    "failed": 0
  }
}

尝试更改查询字符串和all.but无用。在使用上述查询进行搜索时,我也在获取数据。

我正在使用Elasticsearch-PHP Client。

最佳答案

由于您使用的是Elasticsearch 2.1,因此您需要知道按查询删除功能是removed from the coremoved into a dedicated plugin

您需要先安装该插件才能使PHP代码正常工作。

./bin/plugin install delete-by-query

关于php - 如何使用php从Elasticsearch批量删除文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33956117/

相关文章:

elasticsearch - 我不认为我完全了解Elastic Search

r - 在 R 的 ompr 包中,如何重新表述我的目标/约束/变量以避免 "problem too large"错误?

php - 通过 PHP 使用 _POST 和 _GET 过滤和排序 Postgres 表

ruby-on-rails-3 - 轮胎上Elasticsearch的精确词组匹配

php - Paypal - 可以使用 web_accept 通过 RESTFUL API 退款

c# - 从 NEST C# 嵌套聚合获取 Elasticsearch 结果

java - Apache Storm 上为 Bolt 添加重试机制

database - 大数据去了哪里以及如何存储?

php - Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException 没有消息 Laravel 5.5

php - file_get_contents() 在不同机器上的工作方式不同