Introduction
suggest changeElasticSearch has a well-documented JSON API, but you’ll probably want to use some libraries that handle that for you:
Elasticsearch- the official low level wrapper for the HTTP APIElasticsearch-rails- the official high level Rails integration that helps you to connect your Rails models with ElasticSearch using either ActiveRecord or Repository patternChewy- An alternative, non-official high level Rails integration that is very popular and arguably has better documentation
Let’s use the first option for testing the connection:
gem install elasticsearch
Then fire up the ruby terminal and try it out:
require 'elasticsearch'
client = Elasticsearch::Client.new log: true
# by default it connects to http://localhost:9200
client.transport.reload_connections!
client.cluster.health
client.search q: 'test'
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents