Redis 使用 redis-search 报错!

zhaoguobin · November 03, 2011 · Last by huacnlee replied at February 04, 2012 · 3404 hits

在rails工程(mysql)的model中添加:
```redis_search_index(:title_field => :title)```
数据库中有title字段。

报错:

Now indexing search to Redis...

rake aborted! You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.each

/home/zhao/.rvm/gems/ruby-1.9.2-p180/gems/redis-search-0.7.0/lib/redis/search/tasks.rb:12:in `block (2 levels) in ' ......

哦,这个是一个索引应用的问题,请在 application.rb 里面 调用一下 有定义 redis_search_index 的 Model, Model.new 一下就可以了,不然 redis_search_index 没法知道有那些 Model,这个问题我会在后面想办法解决,Mongoid 没有这个问题。 比如

class Post < ActiveRecord::Base
  redis_search_index(:title_field => :title)
end

application.rb

Post.new

另外,Bug 可以提交到 Github 上面去,这个东西明显只有我能回答,发这里没意义啊

You need to Sign in before reply, if you don't have an account, please Sign up first.