【发布时间】:2012-10-22 16:40:08
【问题描述】:
感谢您抽出宝贵时间
问题
我在基于模糊名称搜索和精确区域搜索来搜索记录时遇到问题。这就是我现在拥有的:
我现在拥有的
# :klantnaam is a param from a search-form
@param = Staffingcustomer.search do
fulltext params[:klantnaam]
end
@staffingcustomers = @param.results
还有另一个字段,“区域”。
结果应该只包含某个“区域”。
示例要求
例如,
我是 Regio 3 的用户。
我想使用模糊名称搜索 Anne 和我自己的 Regio 3 可视化/选择所有 Staffingcustomers。所以,我不想看到带有 Regio 2 的 Staffingcustomers。
现在发生的是:
@param = Staffingcustomer.search do
fulltext 'anne'
end
@staffingcustomers = @param.results
将返回所有不同区域的所有 Staffingcustomers...
经过一些研究/逻辑思考
我认为可能是这样的:
@param = Staffingcustomer.search do
fulltext params[:klantnaam]
end
@staffingcustomers = @param.results.find(:all, :conditions => {:regio => 3})
或
@param = Staffingcustomer.search do
fulltext params[:klantnaam] and fulltext '3' ## or 3, without the quotes
end
@staffingcustomers = @param.results
但这似乎不起作用。
你能帮我解决这个问题吗?
逻辑问题
实际上,这是对一个巨大表的“精确选择”部分的模糊搜索。
希望你能帮忙。
提前致谢。
Kers。
【问题讨论】:
标签: ruby-on-rails-3 solr sunspot-rails fuzzy-search exact-match