I want to delete records which match date range with Elastica
query of elasticsearch
to delete records
curl -XDELETE 'http://localhost:9200/twitter/tweet/_query' -d '{
"query": {
"range" : {
"age" : {
"gte" : 10,
"lte" : 20,
"boost" : 2.0
}
}
}
} '
How to this query with Elastica ?
Something like this should do:
$age_range = new NumericRange('age', array(
'gte' => 10,
'lte' => 20,
'boost' => 2.0
));
$client->getIndex("index-name")->deleteByQuery($age_range);
Note that if you are running ES 2.x (any version), you need to install the delete-by-query plugin first. If you are running ES 1.x or 5.x you don't need to install any additional plugin.