Skip to content

Commit

Permalink
Keep using multi_json internally
Browse files Browse the repository at this point in the history
  • Loading branch information
walm committed Jun 24, 2014
1 parent 362d83d commit 0cbedb7
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/stretcher.rb
Expand Up @@ -2,7 +2,7 @@
require 'logger'
require 'hashie'
require 'excon'
require 'json'
require 'multi_json'
require 'faraday'
require 'faraday_middleware'
require "stretcher/version"
Expand Down
4 changes: 2 additions & 2 deletions lib/stretcher/index.rb
Expand Up @@ -61,8 +61,8 @@ def bulk_action(action, documents, options={})
index_meta[key] = d.delete(key) if system_fields.include?(key.to_s)
end

post_data << (JSON.dump({action => index_meta}) << "\n")
post_data << (JSON.dump(d) << "\n") unless action == :delete
post_data << (MultiJson.dump({action => index_meta}) << "\n")
post_data << (MultiJson.dump(d) << "\n") unless action == :delete
post_data
}
bulk body, options
Expand Down
2 changes: 1 addition & 1 deletion lib/stretcher/server.rb
Expand Up @@ -142,7 +142,7 @@ def up?
# server.msearch(data)
def msearch(body=[])
raise ArgumentError, "msearch takes an array!" unless body.is_a?(Array)
fmt_body = body.map {|l| JSON.dump(l) }.join("\n") << "\n"
fmt_body = body.map {|l| MultiJson.dump(l) }.join("\n") << "\n"

res = request(:get, path_uri("/_msearch"), {}, fmt_body, {}, :mashify => false)

Expand Down
2 changes: 1 addition & 1 deletion lib/stretcher/util.rb
Expand Up @@ -3,7 +3,7 @@ module Util

# cURL formats a Faraday req. Useful for logging
def self.curl_format(req)
body = "-d '#{req.body.is_a?(Hash) ? JSON.dump(req.body) : req.body}'" if req.body
body = "-d '#{req.body.is_a?(Hash) ? MultiJson.dump(req.body) : req.body}'" if req.body
headers = req.headers.map {|name, value| "'-H #{name}: #{value}'" }.sort.join(' ')
method = req.method.to_s.upcase
url = Util.qurl(req.path,req.params)
Expand Down

0 comments on commit 0cbedb7

Please sign in to comment.