Deprecated! High performance real-time prefix search, indexes store in Redis for Rails application
Deprecated! High performance real-time prefix search, indexes store in Redis for Rails application
High performance real-time prefix search, indexes store in Redis for Rails application. 中文介绍和使用说明
There have more better ways you can choice!
下面的两种方式将是更好的选择:
gem 'redis-search'$ bundle install…Redis::Search callback event, it will to rebuild search indices when data create or update.class Post < ActiveRecord::Base
include Redis::Search
belongs_to :user
belongs_to :category
redis_search title_field: :title,
score_field: :hits,
condition_fields: [:user_id, :category_id],
ext_fields: [:category_name]
def category_name
self.category.name
end
endclass User < ActiveRecord::Base
include Redis::Search
serialize :alias_names, Array
redis_search title_field: :name,
alias_field: :alias_names,
score_field: :followers_count,
ext_fields: [:email, :tagline]
endclass SearchController < ApplicationController
# GET /search_users?q=j
def search_users
Post.prefix_match(params[:q], conditions: { user_id: 12, category_id: 4 })
end
endRedis-Search index data to Redis from your model (pass name as CLASS environment variable).
$ rake redis_search:index:model CLASS='User'Customize the batch size:
$ rake redis_search:index:model CLASS='User' BATCH=100Redis-Search all index data to Redis from app/models (or use DIR environment variabl).
$ rake redis_search:index DIR=app/modelsCustomize the batch size:
$ rake redis_search:index DIR=app/models BATCH=100You can run the rake command (see Rakefile) to make test. There is my performance test result.
Projects used redis-search:
No open issues yet, or sync has not completed.