Ultrasphinx 和 Rails:完全错误的结果 - 为什么?
我正在使用 Ultrasphinx 在 Rails 应用程序上进行搜索。一切似乎都正常,唯一的问题是搜索结果与搜索查询不匹配。我实在不明白这个。我多次重建索引和配置文件,但似乎没有任何效果。当我搜索“测试”时,我得到的结果在任何列中都没有“测试”一词。
这仅发生在我的生产服务器上。在开发环境中一切正常。
我真的不知道该向您提供哪些信息,我只是将我的设置粘贴到模型和控制器中。
# models/video.rb
is_indexed :fields => ['title', 'description', 'id'],
:concatenate => [{:class_name => 'Tag',
:association_sql => "LEFT OUTER JOIN tags_videos ON (videos.id = tags_videos.video_id) LEFT OUTER JOIN tags ON (tags_videos.tag_id = tags.id)",
:field => 'name', :as => 'tagstring'}],
:order => "videos.created_at DESC",
:eagerly_load => [:tags],
:delta => true
# models/tag.rb
is_indexed :fields => ['name'],
:delta => true
# controllers/searches_controller
class SearchesController < ApplicationController
def search
@search_query = (params[:query]) ? params[:query] : nil
unless @search_query.nil?
# set the search options
search_options = {:query => @search_query,
:page => (params[:page] || 1),
:weights => {'title' => 2.0, 'description' => 1.0, 'tagstring' => 1.0},
:per_page => 40,
:class_names => ["Video"],
:sort_mode => 'relevance'}
@search = Ultrasphinx::Search.new(search_options)
Ultrasphinx::Search.client_options['ignore_missing_records'] = true
@search.run
@videos = @search.results
end
end
end
运行 rake ultrasphinx:configure 时我也会收到此错误,
Rebuilding configurations for production environment
Available models are Tagtranslation missing: en_US, support, array, two_words_connectorVideo
Generating SQL
但我不知道这与它有什么关系。
感谢您的帮助!
I'm using Ultrasphinx for searching on a Rails App. Everything seems to be working, the only thing is that the search results are not matching the search query in any way. I really don't understand this. I rebuilt my indexes and config files several times and nothing seems to work. When I perform a search for "test" I get results back without the word "test" in any column.
This only happens on my production server. In the development environment everything works fine.
I don't really know which information to provide you with, I just paste my setup in the models and controllers
# models/video.rb
is_indexed :fields => ['title', 'description', 'id'],
:concatenate => [{:class_name => 'Tag',
:association_sql => "LEFT OUTER JOIN tags_videos ON (videos.id = tags_videos.video_id) LEFT OUTER JOIN tags ON (tags_videos.tag_id = tags.id)",
:field => 'name', :as => 'tagstring'}],
:order => "videos.created_at DESC",
:eagerly_load => [:tags],
:delta => true
# models/tag.rb
is_indexed :fields => ['name'],
:delta => true
# controllers/searches_controller
class SearchesController < ApplicationController
def search
@search_query = (params[:query]) ? params[:query] : nil
unless @search_query.nil?
# set the search options
search_options = {:query => @search_query,
:page => (params[:page] || 1),
:weights => {'title' => 2.0, 'description' => 1.0, 'tagstring' => 1.0},
:per_page => 40,
:class_names => ["Video"],
:sort_mode => 'relevance'}
@search = Ultrasphinx::Search.new(search_options)
Ultrasphinx::Search.client_options['ignore_missing_records'] = true
@search.run
@videos = @search.results
end
end
end
I also get this error when running rake ultrasphinx:configure
Rebuilding configurations for production environment
Available models are Tagtranslation missing: en_US, support, array, two_words_connectorVideo
Generating SQL
but I don't know, what that has to do with it.
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以通过安装 Sphinx 0.9.9 来解决这个问题,使用选项
->; http://www.sphinxsearch.com/docs/current.html#installing
之后,我删除了所有旧索引,重新创建了配置文件,重新创建了索引并重新启动了 ultrasphinx 守护进程。
不管怎样,谢谢。
I could fix the problem by installing Sphinx 0.9.9, using the option
-> http://www.sphinxsearch.com/docs/current.html#installing
After that I removed all old indexes, recreated the configuration file, recreated the index and restartet the ultrasphinx daemon.
Thanks anyway.