Rails3.1.1 和 sunspot:Solr 响应:未找到错误

发布于 2024-12-18 12:31:42 字数 2063 浏览 1 评论 0原文

我正在尝试使用 sunspot_solr 构建一个应用程序,但不断收到此错误:

rsolr (0.12.1) lib/rsolr/connection/requestable.rb:39:in `request'
rsolr (0.12.1) lib/rsolr/client.rb:34:in `request'
sunspot (1.2.1) lib/sunspot/search/abstract_search.rb:35:in `execute'
sunspot_rails (1.2.1) lib/sunspot/rails/searchable.rb:306:in `solr_execute_search'
sunspot_rails (1.2.1) lib/sunspot/rails/searchable.rb:139:in `solr_search'
app/controllers/search_controller.rb:7:in `results'

这是我的 sunspot.yml:

solr:
    hostname: localhost
    port: 8980
    log_level: INFO
    path: /solr
    pid_dir: /solr/pids/development
    auto_commit_after_delete_request: true

solr 实例位于 http://localhost:8980/solr/admin/ 确实有效,当我在那里运行查询时,我得到了所有想要的结果。但是当我运行我的应用程序时,我收到上述错误。

我的配置: 导轨3.1.1 太阳黑子:1.2.1

请告诉我您还需要我提供哪些其他信息,并提前感谢您的答复。

我查看了日志文件并发现了此错误:

DEPRECATION WARNING: class_inheritable_attribute is deprecated, please use class_attribute method instead. Notice their behavior are slightly different, so refer to class_attribute documentation first. (called from <class:User> at /home/romio/hummingtown_v1/app/models/user.rb:17)

这是我的 user.rb:

require 'digest/sha2'

class User < ActiveRecord::Base

    has_many :userauths, :dependent => :destroy

    attr_accessor :password
    attr_accessible :first_name, :last_name, :email, :password, :salt

    email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i

    validates :first_name, :presence => true, :length => { :maximum => 50 }
    validates :last_name, :presence => true, :length => { :maximum => 50 }
    validates :email, :presence => true, :format => { :with => email_regex }, 
                :uniqueness => { :case_sensitive => false }

    searchable :auto_index => true, :auto_remove => true do
        text :first_name, :default_boost => 2
        text :last_name
        text :email
    end

I'm trying to build an application with sunspot_solr and I keep getting this error:

rsolr (0.12.1) lib/rsolr/connection/requestable.rb:39:in `request'
rsolr (0.12.1) lib/rsolr/client.rb:34:in `request'
sunspot (1.2.1) lib/sunspot/search/abstract_search.rb:35:in `execute'
sunspot_rails (1.2.1) lib/sunspot/rails/searchable.rb:306:in `solr_execute_search'
sunspot_rails (1.2.1) lib/sunspot/rails/searchable.rb:139:in `solr_search'
app/controllers/search_controller.rb:7:in `results'

Here is my sunspot.yml:

solr:
    hostname: localhost
    port: 8980
    log_level: INFO
    path: /solr
    pid_dir: /solr/pids/development
    auto_commit_after_delete_request: true

And the solr instance at http://localhost:8980/solr/admin/ does work, I get all the desired results when I run the queries there. But when I run through my application I get the above error.

My configuration:
Rails 3.1.1
Sunspot: 1.2.1

Please let me know what other information you need from me and thanks in advance for the answers.

I went through the logs files and found out this error:

DEPRECATION WARNING: class_inheritable_attribute is deprecated, please use class_attribute method instead. Notice their behavior are slightly different, so refer to class_attribute documentation first. (called from <class:User> at /home/romio/hummingtown_v1/app/models/user.rb:17)

Here is my user.rb:

require 'digest/sha2'

class User < ActiveRecord::Base

    has_many :userauths, :dependent => :destroy

    attr_accessor :password
    attr_accessible :first_name, :last_name, :email, :password, :salt

    email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i

    validates :first_name, :presence => true, :length => { :maximum => 50 }
    validates :last_name, :presence => true, :length => { :maximum => 50 }
    validates :email, :presence => true, :format => { :with => email_regex }, 
                :uniqueness => { :case_sensitive => false }

    searchable :auto_index => true, :auto_remove => true do
        text :first_name, :default_boost => 2
        text :last_name
        text :email
    end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文