Skip to content

Instantly share code, notes, and snippets.

@tadyjp
Last active October 4, 2017 15:22
Show Gist options
  • Save tadyjp/c5afbd85fd00e6f91d3deba7c20a38c1 to your computer and use it in GitHub Desktop.
Save tadyjp/c5afbd85fd00e6f91d3deba7c20a38c1 to your computer and use it in GitHub Desktop.
AWS Elasticsearch Serviceが律儀にgzipを返すようになって死んだ [解決済み] ref: http://qiita.com/tady/items/eb924cc06e8c1ed5ae9a
Elasticsearch::Model.client = Elasticsearch::Client.new(
host: ENV.fetch('ELASTICSEARCH_ENDPOINT'),
port: 80
) do |faraday|
faraday.use FaradayMiddleware::Gzip # ここを追加
faraday.request :aws_signers_v4,
credentials: Aws::Credentials.new(ENV.fetch('AWS_KEY_ID'), ENV.fetch('AWS_ACCESS_KEY')),
service_name: 'es',
region: 'ap-northeast-1'
faraday.adapter Faraday.default_adapter
end
MultiJson::ParseError: unexpected character at line 1, column 1 [parse.c:664]
elasticsearch (5.0.0)
elasticsearch-api (5.0.0)
elasticsearch-transport (5.0.0)
elasticsearch-dsl (0.1.4)
elasticsearch-model (0.1.9)
elasticsearch-rails (0.1.9)
elasticsearch-transport (5.0.0)
faraday (0.9.2)
faraday_middleware (0.12.2)
faraday_middleware-aws-signers-v4 (0.1.5)
# This middleware is NOT necessary when these adapters are used:
# - net_http on Ruby 1.9+
# - net_http_persistent on Ruby 2.0+
# - em_http
if Net::HTTP::HAVE_ZLIB
env.request_headers['Accept-Encoding'] ||= 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3'
end
...
gem 'faraday_middleware'
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment