Skip to content

Instantly share code, notes, and snippets.

@reggieb
Last active January 24, 2017 09:00
Show Gist options
  • Save reggieb/d44cafe1e84dd1adceb6894405261147 to your computer and use it in GitHub Desktop.
Save reggieb/d44cafe1e84dd1adceb6894405261147 to your computer and use it in GitHub Desktop.
require 'elasticsearch'
# Set up client bypassing Elasticsearch's Faraday imported proxy settings (which ignore system's no_proxy)
# So transport_options needed to access local elasticsearch instance
client = Elasticsearch::Client.new log: true, transport_options: { proxy: '' }
# Retrieve data - setup instructions here:
# https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-elasticsearch-on-ubuntu-16-04
client.get index: 'tutorial', type: 'helloworld', id: 1
# Create a entry:
client.create index: 'foo', type: 'bar', id: 2, body: {message: 'Hello there!'}
# Search query:
client.search index: 'foo', type: 'bar', body: { query: { match: {message: 'hello'}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment