Stretchy provides Elasticsearch/Opensearch models in Rails applications with an Rails-like model interface.
Stretchy simplifies the process of querying, aggregating, and managing Elasticsearch-backed models, allowing Rails developers to work with search indices as comfortably as they would with traditional Rails models.
queries
, scopes
and aggregations
StretchyModel
Follow the guides to learn more about:
Read the Documentation or follow the examples below:
Examples
Install the gem and add to the application's Gemfile by executing:
bundle add stretchy-model
If bundler is not being used to manage dependencies, install the gem by executing:
gem install stretchy-model
[!TIP] If using OpenSearch make sure to add the gem to your Gemfile.
bundle add opensearch-ruby
config/initializers/stretchy.rb
```ruby Stretchy.configure do |config| config.client = Elasticsearch::Client.new Rails.application.credentials.elasticsearch # or if using OpenSearch # config.client = OpenSearch::Client.new Rails.application.credentials.opensearch end ```After checking out the repo, run bin/setup
to install dependencies. You can also run bin/console
for an interactive prompt that will allow you to experiment.
[!TIP] Full documentation on Elasticsearch Query DSL and Aggregation options
Bug reports and pull requests are welcome on GitHub at https://github.com/theablefew/stretchy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.