Skip to content

Instantly share code, notes, and snippets.

@IanWhitney
Last active December 11, 2015 06:49
Show Gist options
  • Select an option

  • Save IanWhitney/4562057 to your computer and use it in GitHub Desktop.

Select an option

Save IanWhitney/4562057 to your computer and use it in GitHub Desktop.
Setting up and using a text search field in redis.
Movies.each do |movie|
$redis.set "title_search:#{movie.title}", "#{movie.id}"
End
search_string = "titanic"
matching_keys = $redis.keys "title_search:*#{search_string}*"
matched_ids = []
matching_keys.each do |key|
matched_ids << $redis.get(key)
end
Movie.find(matched_ids)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment