搜索引擎 Solr 报错

kitt · 2013年10月27日 · 最后由 kitt 回复于 2013年10月28日 · 8390 次阅读
irb(main):001:0> User.reindex
  SOLR Request (71.2ms)  [ path=#<RSolr::Client:0x0000000376f388> parameters={data: <?xml version="1.0" encoding="UTF-8"?><delete><query>type:User</query></delete>, headers: {"Content-Type"=>"text/xml"}, method: post, params: {:wt=>:ruby}, query: wt=ruby, path: update, uri: http://localhost:8080/solr/update?wt=ruby, open_timeout: , read_timeout: , retry_503: , retry_after_limit: } ]
RSolr::Error::Http: RSolr::Error::Http - 400 Bad Request
Error: {'responseHeader'=>{'status'=>400,'QTime'=>1},'error'=>{'msg'=>'undefined field type','code'=>400}}

Request Data: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><delete><query>type:User</query></delete>"

Backtrace: /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rsolr-1.0.9/lib/rsolr/client.rb:268:in `adapt_response'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/rsolr-1.0.9/lib/rsolr/client.rb:175:in `execute'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/rsolr-1.0.9/lib/rsolr/client.rb:161:in `send_and_receive'
(eval):2:in `post'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/rsolr-1.0.9/lib/rsolr/client.rb:67:in `update'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/rsolr-1.0.9/lib/rsolr/client.rb:131:in `delete_by_query'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/sunspot-2.0.0/lib/sunspot/indexer.rb:57:in `remove_all'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/sunspot-2.0.0/lib/sunspot/session.rb:181:in `block in remove_all'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/sunspot-2.0.0/lib/sunspot/session.rb:181:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/sunspot-2.0.0/lib/sunspot/session.rb:181:in `remove_all'
/usr/local/rvm/gems/ruby-1.9.3-p392/gems/sunspot-2.0.0/lib/sunspot/session_proxy/abstract_session_proxy.rb:11:in `remove_all'
        from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rsolr-1.0.9/lib/rsolr/client.rb:268:in `adapt_response'
        from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rsolr-1.0.9/lib/rsolr/client.rb:175:in `execute'
        from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rsolr-1.0.9/lib/rsolr/client.rb:161:in `send_and_receive'
        from (eval):2:in `post'
        from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rsolr-1.0.9/lib/rsolr/client.rb:67:in `update'
        from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rsolr-1.0.9/lib/rsolr/client.rb:131:in `delete_by_query'
        from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/sunspot-2.0.0/lib/sunspot/indexer.rb:57:in `remove_all'
        from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/sunspot-2.0.0/lib/sunspot/session.rb:181:in `block in remove_all'
        from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/sunspot-2.0.0/lib/sunspot/session.rb:181:in `each'
        from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/sunspot-2.0.0/lib/sunspot/session.rb:181:in `remove_all'
        from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/sunspot-2.0.0/lib/sunspot/session_proxy/abstract_session_proxy.rb:11:in `remove_all'
        from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/sunspot-2.0.0/lib/sunspot.rb:464:in `remove_all'
        from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/sunspot_rails-2.0.0/lib/sunspot/rails/searchable.rb:183:in `solr_remove_all_from_index'
        from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/sunspot_rails-2.0.0/lib/sunspot/rails/searchable.rb:202:in `solr_reindex'
        from (irb):1
        from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands/console.rb:47:in `start'
        from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands/console.rb:8:in `start'
        from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands.rb:41:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'irb(main):002:0>

新建 user 引擎报这个错,tomcat+solr,单独登陆 solr 分词可以正常使用,就是通过项目使用 solr 就报错了,不知道哪里错了,无从下手。

是不是这句啊?

Error: {'responseHeader'=>{'status'=>400,'QTime'=>1},'error'=>{'msg'=>'undefined field type','code'=>400}}

检查一下 solr 那边的 schema

谢谢,问题已解决。知道哪里的问题了

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册