Elastic Search to a
Ruby on Rails application can be a bit tricky, as there isn't any end to end documentation for the same, like how to install and run elastic search for development, staging and production, how to add analyzers and tokenizers for any fields in db, how to add filters and all.
This is a series of posts for the same, we will cover the above topics in 3 parts:
- Install elastic search(with docker)
- Add logic to Rails application
- Implement Search
In this post we will cover the first part, installing elastic search.
We will be using
docker-compose for this, as its really handy and requires only a few lines of code to get it up and running.
dockeron your system. I prefer ubuntu or any such single box, and use it for
qaenvironments with different index names for different developers in dev and environments.
You can find instructions over here.
docker-compose. Relevant instructions can be found here.
- ssh into the server you want to install elastic search on.
- Create a folder for elastic search in a convenient location.
mkdir ~/elastic-searchshould be good enough.
- Create and edit a new file
- Enter the content from this link in that file.
- Edit the file
vim /etc/sysctl.confand append a line in the end:
- You can reboot the server, for the change to take effect, or run
sudo sysctl -w vm.max_map_count=262144for changes in the current session.
- Now head over to the folder elastic-search like
sudo docker-compose up -d
- This should fire up the elastic search server on port 9292.
- After a few seconds run
It should return a
jsonobject with tagline
You know, for Search.
Now we are ready for our next step! Integrating this elastic search with our Ruby on Rails application.!!