Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Code Climate Inline docs Gem Version

This gems simplifies integration with RediSearch module ( This software is of Alpha quality and is provided with no warranties whatsoever. Additionally RediSearch is still not officially released so major features may change.


Install Redis and RediSearch following instructions on Until modules are released with Redis 4 this requires compiling Redis from unstable branch from GitHub.

Add this line to your application's Gemfile:

gem 'redi_search_rails'

And then execute:

$ bundle

Or install it yourself as:

$ gem install redi_search_rails


Create config/initializers/redi_search_rails.rb

REDI_SEARCH = '', port: '6379')


class User < ApplicationRecord
  include RediSearchRails
  redi_search_schema   name: 'TEXT', email: 'TEXT', age: 'NUMERIC'
# => to create index run in rails console
# => populate index with records for all users
# => or you can do it for specific record
User.ft_add(User.where(id: 1))
# => search
User.ft_search(keyword: 'keyword here', offset: 0, num: 10)
# => output
[1, "gid://application_name/User/unique_id", ["name", "Bob", "age", "100"]]
# => format results as array of objects
User.ft_search_format(keyword: 'keyword here', offset: 0, num: 10)
# => output
[{"id": "gid://application_name/User/unique_id", "name": "Bob", "age": "100"}, {...}]
# => for autocomplete
User.ft_sugadd(record: user, attribute: name)

As unique identifier (doc_id) for records in Redis this gem uses GlobalID. You need to make sure your models support it if you are using ORM other than ActiveRecord.


After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment. To understand the code look in lib/redi_search_rails.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to


Testing this gem requires having local Redis with RediSearch module. This makes it very difficult to set it up with services like Codeship.


  • ActiveModel callbacks to index records on saving and remove from Redis on delete
  • Rake tasks to manage indexes
  • Support configuring SCORE, WEIGHT and other options
  • Support indexing fields from related models (index group name if user belongs to a group)
  • Support GEO filters
  • Stopwords configuration
  • Minimum keyword length to index
  • Configurable method for doc_id, not just default to_global_id
  • More test coverage and documentation


Bug reports and pull requests are welcome on GitHub at This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.


The gem is available as open source under the terms of the MIT License.


No releases published


No packages published
You can’t perform that action at this time.