Delete by datetime range query

Hi all,

I am trying to delete documents based on their datetime.

datetime field is defined in the mapping as:
"dt":{"type":"date","format":"basic_date_time_no_millis"}

when I query for documents in a specific date range, es answers correctly

curl -XGET 'http://myserver:9200/webindex/result/_search' -d '{"query":{"query_string":{"query":"dt:["20120608T000000+0200" TO "20120608T235959+0200"]"}}}'

when I try to delete the documents, this query fails

curl -XDELETE 'http://myserver:9200/webindex/result/_query' -d '{"query":{"query_string":{"query":"dt:["20120608T000000+0200" TO "20120608T235959+0200"]"}}}'

response is
{"ok":true,"_indices":{"webindex":{"_shards":{"total":5,"successful":0,"failed":5}}}}

elasticsearch.log says:

[2012-06-11 09:29:04,738][DEBUG][action.deletebyquery ] [Blue Shield] [webindex][4], node[Ad-TT9ENRH-UaUB1DC2OHw], [P], s[STARTED]: Failed to execute [delete_by_query {[webindex][result], query [{"query":{"query_string":{"query":"dt:["20120608T000000+0200" TO "20120608T235959+0200"]"}}}]}]
org.elasticsearch.index.query.QueryParsingException: [webindex] No query registered for [query]
at org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:190)
at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:243)
at org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:193)
at org.elasticsearch.index.shard.service.InternalIndexShard.prepareDeleteByQuery(InternalIndexShard.java:363)
at org.elasticsearch.action.deletebyquery.TransportShardDeleteByQueryAction.shardOperationOnPrimary(TransportShardDeleteByQueryAction.java:95)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:532)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:430)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:679)

Are we restricted to simple term queries when using Delete By Query API? Or am I doing something wrong?

when I try to delete the documents, this query fails

curl -XDELETE 'http://myserver:9200/webindex/result/_query' -d
'{"query":{"query_string":{"query":"dt:["20120608T000000+0200" TO
"20120608T235959+0200"]"}}}'

delete-by-query doesn't take the top-level 'query' param. So just pass
it the query_string part

clint

thx Clint, it's good to know.
In the meantime, I overcame the problem using "range" query.

Dionysis

On Tue, Jun 12, 2012 at 12:32 PM, Clinton Gormley clint@traveljury.comwrote:

when I try to delete the documents, this query fails

curl -XDELETE 'http://myserver:9200/webindex/result/_query' -d
'{"query":{"query_string":{"query":"dt:["20120608T000000+0200" TO
"20120608T235959+0200"]"}}}'

delete-by-query doesn't take the top-level 'query' param. So just pass
it the query_string part

clint