Elasticsearch删除按日期查询

时间:2013-08-31 11:21:57

标签: ruby elasticsearch

我正在运行以下查询:

q='{
    "filtered" : {
        "query" : {
            "match_all" : {}
        },
        "filter": {
            "and": [
                {
                    "range": {
                        "creation_time": {
                         "from": "2012-08-30",
                                    "to": "2012-08-31",

                                "include_lower": true,
                                "include_upper": true
                        }
                    }
                },
            ]
        }
    }
}'

我的域名是ec2服务器

curl -XDELETE "http://#{mydomain}:9200/monitoring/mention_reports/_query?q=#{q}"

当我点击此查询时,它会给我

  

curl:(3)在pos 118

不支持[globbing]嵌套大括号

请帮助我谢谢

1 个答案:

答案 0 :(得分:1)

如果你试图从命令行执行curl,它应该看起来像:

q='YOUR_QUERY_CODE_GOES_HERE' 
curl -v -H "Content-type: application/json" -H "Accept: application/json" \
     -XDELETE -d $q http://localhost:9200/monitoring/mention_reports/_query

如果是ruby内部执行,你应该像你一样格式化请求,但是银弹仍在标题中:

-H "Content-type: application/json" -H "Accept: application/json"