1

我想在这样的模型上索引 has_many 关联,但是当我按标签名称搜索时,它找不到记录:

searchable do
  text :name, :author, :toon_type
  text :tags_names do
    tags.map(&:name)
  end
  time :created_at
end

任何想法?我的标签是通过标签模型进行多态关联的,这是一个问题吗?

谢谢

更新

我在我的日志中通过 object.index 手动索引控制台:

SOLR 请求(5.3 毫秒)[路径=# 参数={数据:卡通 86ToonActiveRecord::BaseToon2013-08-22T22:46:09Zpapabearanimation,标题:{“Content-Type”=>“text/xml”},方法:post,参数:{:wt=>:ruby},查询:wt=ruby,路径:更新,uri:xxx:8982/so​​lr/update?wt=ruby,open_timeout:,read_timeout:,retry_503:,retry_after_limit:}]

搜索方法

@search = Sunspot.search(Toon) do
  fulltext params[:search]
  order_by :created_at, :asc
  # with(:created_at).less_than Time.now
  # with(:created_at).greater_than(1.week.ago)
  paginate :page => params[:page], :per_page => 9
end
@toons = @search.results

搜索请求:

SearchController#result 处理为 HTML 参数:{"utf8"=>"✓", "ga_client_id"=>"", "search"=>"testerabc"} 用户负载 (0.5ms) SELECT "users".* FROM " users" WHERE "users"."id" = 5 LIMIT 1 SOLR Request (43.9ms) [ path=# parameters={data: fq=type%3AToon&sort=created_at_d+asc&q=testerabc&fl=%2A+score&qf=name_text+author_text+ toon_type_text+tags_text&defType=dismax&start=0&rows=9,方法:post,参数:{:wt=>:ruby},查询:wt=ruby,标题:{"Content-Type"=>"application/x-www-form- urlencoded; charset=UTF-8"}, path: select, uri: localhost:8982/so​​lr/select?wt=ruby, open_timeout: , read_timeout: , retry_503: , retry_after_limit: } ]

4

0 回答 0