Ultrasphinx 和 Rails:完全错误的结果 - 为什么?

发布于 2024-09-01 14:52:40 字数 1761 浏览 7 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

才能让你更想念 2024-09-08 14:52:40

我可以通过安装 Sphinx 0.9.9 来解决这个问题,使用选项

--prefix=/usr/local/sphinx

->; http://www.sphinxsearch.com/docs/current.html#installing

之后,我删除了所有旧索引,重新创建了配置文件,重新创建了索引并重新启动了 ultrasphinx 守护进程。

不管怎样,谢谢。

I could fix the problem by installing Sphinx 0.9.9, using the option

--prefix=/usr/local/sphinx

-> 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文