Add Elasticsearch without external dependencies #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why
The goal of the
rails-example
application is to serve as an example web application for learning how to deploy apps to the Reclaim the Stack platform. Currently it uses Postgres and Redis but since the platform also supports Elasticsearch we want the demo application to use this as well.What
Indexes the
Post
andLink
models into asearchable
Elasticsearch index to allow for doing full text search across both models. Each document in the index will use atitle
field with a high priority and acontent
field with lower priority (taken fromPost#body
andLink#description
respectively).This implementation uses
Net::HTTP
to interact with Elasticsearch, without involving any extra dependencies.Feel free to compare with #2 which is based on
elasticsearch-rails
.Lines of Code
Implementation: ~200 LOC
Dependencies: 0 LOC
Time spent
Didn't keep track but approximately 2 hours.
Issues
None
Learnings
I learnt a few things about the Elasticsearch API which will come in handy when working with and debugging Elasticsearch in the future. I also learnt how to use
Net::HTTP
directly, which though not as streamlined as alternative HTTP clients, isn't the end of the world.