High performance real-time search (Support Chinese), indexes store in Redis for Rails application
Pull request Compare This branch is 159 commits behind huacnlee:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
.gitignore
README.markdown
redis-search.gemspec

README.markdown

RedisSearch

High performance real-time search (Support Chinese), index in Redis for Rails application

Features

  • Real-time search
  • High performance

Requirements

  • Redis 2.2
  • Libmmseg

Install

  • gem install redis-search

Configure

create file in: config/initializers/redis_search.rb

require "redis_search"
redis = Redis.new(:host => "127.0.0.1",:port => "6379")
redis.select("app_name.search")
RedisSearch.configure do |config|
 config.redis = redis
end

Usage

bind RedisSearch callback event, it will to rebuild search indexes when data create or update.

class Post
  include Mongoid::Document
  include RedisSearch

  field :title
  field :body

  belongs_to :user
  belongs_to :category

  redis_search_index(:title_field => :title,
                     :ext_fields => [:category_name])

  def category_name
    self.category.name
  end
end

# GET /searchs?q=title
class SearchController < ApplicationController
  def index
    RedisSearch::Search.query(params[:q], :type => "Post")
  end
end

Demo

You can try the search feature in zheye.org