2016-11-19 80 views
0

我想删除记录删除记录如何使用Elastica删除记录?

curl -XDELETE 'http://localhost:9200/twitter/tweet/_query' -d '{ 
"query": { 
     "range" : { 
      "age" : { 
       "gte" : 10, 
       "lte" : 20, 
       "boost" : 2.0 
      } 
     } 
    } 
} ' 

如何这个查询与弹性曲线,其匹配日期范围的elasticsearchElastica

查询?

回答

1

像这样的东西应该做的:

$age_range = new NumericRange('age', array(
    'gte' => 10, 
    'lte' => 20, 
    'boost' => 2.0 
)); 
$client->deleteByQuery($age_range); 

注意,如果你正在运行ES 2.x的(任何版本),您需要安装delete-by-query plugin第一。如果您正在运行ES 1.x或5.x,则无需安装任何其他插件。

+0

我不能在我的elastica中找到deleteByQuery()函数,这个函数是什么? – jamal

+0

你可以在这里找到它:https://github.com/ruflin/Elastica/blob/18b0c890c92744bdd5bd47cc1fc229b9dcd83263/lib/Elastica/Index.php#L151-L156 – Val

+0

非常感谢你 – jamal