0

我的查询是这个

q = '{ "script":"ctx._source.id = val", "params":{ "val":11316623} }'
   _id="11316623"
   response = JSON.parse(RestClient.post("http://mydomain:9200/monitoring/mention_reports/#{_id}/_delete", q))

它给了我们

/usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/abstract_response.rb:48:in `return!': 400 Bad Request (RestClient::BadRequest)
    from /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/request.rb:230:in `process_result'
    from /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/request.rb:178:in `transmit'
    from /usr/lib/ruby/1.8/net/http.rb:543:in `start'
    from /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in `transmit'
    from /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute'

    from /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute'

from /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.7/lib/restclient.rb:72:in `post'

请帮我

4

1 回答 1

1

请这样做

 mydomain = "ec2-222-333-444-244.us-west-1.compute.amazonaws.com"
 q= '{ "script":"ctx._source.id = val", "params":{ "val":11316623} }'
 _id = "11316623"
 response = RestClient.post "http://#{mydomain}/monitoring/mention_reports/#{_id}/_delete", :q => q, :content_type => :json, :accept => :json
 json_res = JSON.parse(response) 

它应该是

RestClient.post 'http://example.com/resource', :param1 => 'one', :nested => { :param2 => 'two' }以这种格式

于 2013-08-30T08:00:23.137 回答