Rails 应用程序:Solr 在执行搜索时抛出 RSolr::Error::Http - 404 Not Found

Posted

技术标签:

【中文标题】Rails 应用程序:Solr 在执行搜索时抛出 RSolr::Error::Http - 404 Not Found【英文标题】:Rails app: Solr throwing RSolr::Error::Http - 404 Not Found when executing search 【发布时间】:2013-11-14 14:38:48 【问题描述】:

非常迷茫,因为我没有对一直有效的搜索进行任何更改,但不知何故我已经休息了。对于 Rails 来说相对较新,错误输出并没有给我足够的调试细节。

下面的相关代码 - 询问您是否想查看其他内容。

home.html.slim(搜索表单摘录)

= form_tag search_venues_path, method: :get, id: 'search' do |f|
  .search-fields.span16
    p = text_field_tag :q, '', placeholder: "Search for coffee, hotel, etc", class: 'span7 search-field'
    p = text_field_tag :zip, '', placeholder: "Zip code or city name", class: 'span4 search-field'
    p = submit_tag "Find it", class: "btn-main span4"
    br
    = hidden_field_tag :latitude, ''
    = hidden_field_tag :longitude, ''
    p.current_location.hidden.offset1
      a Use my current location

VenuesController.rb(带搜索功能的节选)

def search
  if params[:zip].blank? && params[:latitude].blank?
    flash[:notice] = 'You must include a location to search.'
    return redirect_to(root_path)
  end

  @venues = VenueSearch.search(params)
  #@json = Venue.all.to_gmaps4rails
end

VenueSearch.rb

def self.search(params)
  if params[:zip].present?
    logger.info "The zip code is present"
    logger.debug(Geocoder.coordinates(params[:zip]))
    lat, long = Geocoder.coordinates(params[:zip])
  else
    lat = params[:latitude]
    long = params[:longitude]
  end

  fake_distance = 20 * 0.6214 # 1.5 miles

  Venue.search(include: [:venue_category, :venue_subcategory]) do
    fulltext params[:q].gsub(/[^\s\w]/, ''), minimum_match: 2 do
      boost_fields name: 5.0, name_without_punc: 5.0, category: 3.5, subcategory: 3.5, tags: 4.0
    end

    paginate page: params[:page]
    order_by_geodist :location, lat, long
    with(:location).in_radius(lat, long, fake_distance)
  end
end

错误,完整跟踪

rsolr (1.0.9) lib/rsolr/client.rb:268:in `adapt_response'
rsolr (1.0.9) lib/rsolr/client.rb:175:in `execute'
rsolr (1.0.9) lib/rsolr/client.rb:161:in `send_and_receive'
sunspot_rails (2.1.0) lib/sunspot/rails/solr_instrumentation.rb:16:in `block in send_and_receive_with_as_instrumentation'
activesupport (3.2.2) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.2) lib/active_support/notifications.rb:123:in `instrument'
sunspot_rails (2.1.0) lib/sunspot/rails/solr_instrumentation.rb:15:in `send_and_receive_with_as_instrumentation'
(eval):2:in `post'
sunspot (2.1.0) lib/sunspot/search/abstract_search.rb:45:in `execute'
sunspot_rails (2.1.0) lib/sunspot/rails/searchable.rb:344:in `solr_execute_search'
sunspot_rails (2.1.0) lib/sunspot/rails/searchable.rb:158:in `solr_search'
app/models/venue_search.rb:14:in `search'
app/controllers/venues_controller.rb:12:in `search'
actionpack (3.2.2) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.2) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.2) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.2) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.2) lib/active_support/callbacks.rb:426:in `block in _run__2118553356002381387__process_action__2728035982816219113__callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:215:in `block in _conditional_callback_around_941'
activesupport (3.2.2) lib/active_support/callbacks.rb:326:in `around'
activesupport (3.2.2) lib/active_support/callbacks.rb:310:in `_callback_around_13'
activesupport (3.2.2) lib/active_support/callbacks.rb:214:in `_conditional_callback_around_941'
activesupport (3.2.2) lib/active_support/callbacks.rb:414:in `_run__2118553356002381387__process_action__2728035982816219113__callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.2) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.2) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.2) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.2) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.2) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.2) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.2) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.2) lib/action_controller/metal/params_wrapper.rb:205:in `process_action'
activerecord (3.2.2) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.2) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.2) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.2) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.2) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.2) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:67:in `call'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:67:in `dispatch'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:30:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:594:in `call'
omniauth (1.1.4) lib/omniauth/strategy.rb:184:in `call!'
omniauth (1.1.4) lib/omniauth/strategy.rb:164:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.5) lib/rack/etag.rb:23:in `call'
rack (1.4.5) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/cookies.rb:338:in `call'
activerecord (3.2.2) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `_run__1412551976247017377__call__2752945716229395531__callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.2) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
airbrake (3.1.14) lib/airbrake/rails/middleware.rb:13:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.2) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.2) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.2) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.5) lib/rack/lock.rb:15:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/static.rb:61:in `call'
airbrake (3.1.14) lib/airbrake/user_informer.rb:16:in `_call'
airbrake (3.1.14) lib/airbrake/user_informer.rb:12:in `call'
railties (3.2.2) lib/rails/engine.rb:479:in `call'
railties (3.2.2) lib/rails/application.rb:220:in `call'
railties (3.2.2) lib/rails/railtie/configurable.rb:30:in `method_missing'
rack (1.4.5) lib/rack/deflater.rb:13:in `call'
rack (1.4.5) lib/rack/content_length.rb:14:in `call'
railties (3.2.2) lib/rails/rack/log_tailer.rb:14:in `call'
thin (1.6.1) lib/thin/connection.rb:82:in `block in pre_process'
thin (1.6.1) lib/thin/connection.rb:80:in `catch'
thin (1.6.1) lib/thin/connection.rb:80:in `pre_process'
thin (1.6.1) lib/thin/connection.rb:55:in `process'
thin (1.6.1) lib/thin/connection.rb:41:in `receive_data'
eventmachine (1.0.3) lib/eventmachine.rb:187:in `run_machine'
eventmachine (1.0.3) lib/eventmachine.rb:187:in `run'
thin (1.6.1) lib/thin/backends/base.rb:73:in `start'
thin (1.6.1) lib/thin/server.rb:162:in `start'
rack (1.4.5) lib/rack/handler/thin.rb:13:in `run'
rack (1.4.5) lib/rack/server.rb:268:in `start'
railties (3.2.2) lib/rails/commands/server.rb:70:in `start'
railties (3.2.2) lib/rails/commands.rb:55:in `block in <top (required)>'
railties (3.2.2) lib/rails/commands.rb:50:in `tap'
railties (3.2.2) lib/rails/commands.rb:50:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'

请求参数

 "utf8"=>"✓",
 "q"=>"grill",
 "zip"=>"94107",
 "commit"=>"Find it",
 "latitude"=>"",
 "longitude"=>""

太阳黑子.yml

development:
  solr:
    hostname: localhost
    port: 8983
    log_level: INFO
    path: /solr/development

sunspot-solr-development.log

Nov 3, 2013 10:15:34 PM org.apache.solr.servlet.SolrDispatchFilter init
INFO: SolrDispatchFilter.init()
Nov 3, 2013 10:15:34 PM org.apache.solr.core.SolrResourceLoader locateSolrHome
INFO: JNDI not configured for solr (NoInitialContextEx)
Nov 3, 2013 10:15:34 PM org.apache.solr.core.SolrResourceLoader locateSolrHome
INFO: using system property solr.solr.home: /Users/justin.raczak/Desktop/Desktop-Content/crowdscore/solr
Nov 3, 2013 10:15:34 PM org.apache.solr.core.CoreContainer$Initializer initialize
INFO: looking for solr.xml: /Users/justin.raczak/Desktop/Desktop-Content/crowdscore/solr/solr.xml
Nov 3, 2013 10:15:34 PM org.apache.solr.core.CoreContainer <init>
INFO: New CoreContainer 1884473012
Nov 3, 2013 10:15:34 PM org.apache.solr.core.CoreContainer$Initializer initialize
INFO: no solr.xml file found - using default
Nov 3, 2013 10:15:34 PM org.apache.solr.core.CoreContainer load
INFO: Loading CoreContainer using Solr Home: '/Users/justin.raczak/Desktop/Desktop-Content/crowdscore/solr/'
Nov 3, 2013 10:15:34 PM org.apache.solr.core.SolrResourceLoader <init>
INFO: new SolrResourceLoader for directory: '/Users/justin.raczak/Desktop/Desktop-Content/crowdscore/solr/'
Nov 3, 2013 10:15:34 PM org.apache.solr.handler.component.HttpShardHandlerFactory getParameter
INFO: Setting socketTimeout to: 0
Nov 3, 2013 10:15:34 PM org.apache.solr.handler.component.HttpShardHandlerFactory getParameter
INFO: Setting urlScheme to: http://
Nov 3, 2013 10:15:34 PM org.apache.solr.handler.component.HttpShardHandlerFactory getParameter
INFO: Setting connTimeout to: 0
Nov 3, 2013 10:15:34 PM org.apache.solr.handler.component.HttpShardHandlerFactory getParameter
INFO: Setting maxConnectionsPerHost to: 20
Nov 3, 2013 10:15:34 PM org.apache.solr.handler.component.HttpShardHandlerFactory getParameter
INFO: Setting corePoolSize to: 0
Nov 3, 2013 10:15:34 PM org.apache.solr.handler.component.HttpShardHandlerFactory getParameter
INFO: Setting maximumPoolSize to: 2147483647
Nov 3, 2013 10:15:34 PM org.apache.solr.handler.component.HttpShardHandlerFactory getParameter
INFO: Setting maxThreadIdleTime to: 5
Nov 3, 2013 10:15:34 PM org.apache.solr.handler.component.HttpShardHandlerFactory getParameter
INFO: Setting sizeOfQueue to: -1
Nov 3, 2013 10:15:34 PM org.apache.solr.handler.component.HttpShardHandlerFactory getParameter
INFO: Setting fairnessPolicy to: false
Nov 3, 2013 10:15:34 PM org.apache.solr.client.solrj.impl.HttpClientUtil createClient
INFO: Creating new http client, config:maxConnectionsPerHost=20&maxConnections=10000&socketTimeout=0&connTimeout=0&retry=false
Nov 3, 2013 10:15:35 PM org.apache.solr.core.CoreContainer load
INFO: Registering Log Listener
Nov 3, 2013 10:15:35 PM org.apache.solr.core.CoreContainer create
INFO: Creating SolrCore 'collection1' using instanceDir: /Users/justin.raczak/Desktop/Desktop-Content/crowdscore/solr/collection1
Nov 3, 2013 10:15:35 PM org.apache.solr.core.SolrResourceLoader <init>
INFO: new SolrResourceLoader for directory: '/Users/justin.raczak/Desktop/Desktop-Content/crowdscore/solr/collection1/'
Nov 3, 2013 10:15:35 PM org.apache.solr.core.CoreContainer recordAndThrow
SEVERE: Unable to create core: collection1
org.apache.solr.common.SolrException: Could not load config for solrconfig.xml
at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:991)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:1051)
at org.apache.solr.core.CoreContainer$3.call(CoreContainer.java:634)
at org.apache.solr.core.CoreContainer$3.call(CoreContainer.java:629)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.io.IOException: Can't find resource 'solrconfig.xml' in classpath or '/Users/justin.raczak/Desktop/Desktop-Content/crowdscore/solr/collection1/conf/', cwd=/Users/justin.raczak/.rvm/gems/ruby-1.9.3-p385/gems/sunspot_solr-2.1.0/solr
at org.apache.solr.core.SolrResourceLoader.openResource(SolrResourceLoader.java:318)
at org.apache.solr.core.SolrResourceLoader.openConfig(SolrResourceLoader.java:283)
at org.apache.solr.core.Config.<init>(Config.java:103)
at org.apache.solr.core.Config.<init>(Config.java:73)
at org.apache.solr.core.SolrConfig.<init>(SolrConfig.java:117)
at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:989)
... 11 more
Nov 3, 2013 10:15:35 PM org.apache.solr.common.SolrException log
SEVERE: null:org.apache.solr.common.SolrException: Unable to create core: collection1
at org.apache.solr.core.CoreContainer.recordAndThrow(CoreContainer.java:1672)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:1057)
at org.apache.solr.core.CoreContainer$3.call(CoreContainer.java:634)
at org.apache.solr.core.CoreContainer$3.call(CoreContainer.java:629)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Caused by: org.apache.solr.common.SolrException: Could not load config for solrconfig.xml
at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:991)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:1051)
... 10 more
Caused by: java.io.IOException: Can't find resource 'solrconfig.xml' in classpath or '/Users/justin.raczak/Desktop/Desktop-Content/crowdscore/solr/collection1/conf/', cwd=/Users/justin.raczak/.rvm/gems/ruby-1.9.3-p385/gems/sunspot_solr-2.1.0/solr
at org.apache.solr.core.SolrResourceLoader.openResource(SolrResourceLoader.java:318)
at org.apache.solr.core.SolrResourceLoader.openConfig(SolrResourceLoader.java:283)
at org.apache.solr.core.Config.<init>(Config.java:103)
at org.apache.solr.core.Config.<init>(Config.java:73)
at org.apache.solr.core.SolrConfig.<init>(SolrConfig.java:117)
at org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:989)
... 11 more

Nov 3, 2013 10:15:35 PM org.apache.solr.servlet.SolrDispatchFilter init
INFO: user.dir=/Users/justin.raczak/.rvm/gems/ruby-1.9.3-p385/gems/sunspot_solr-2.1.0/solr
Nov 3, 2013 10:15:35 PM org.apache.solr.servlet.SolrDispatchFilter init
INFO: SolrDispatchFilter.init() done
Nov 3, 2013 10:15:39 PM org.apache.solr.servlet.SolrDispatchFilter handleAdminRequest
INFO: [admin] webapp=null path=/admin/cores params=indexInfo=false&wt=json status=0 QTime=37 
Nov 3, 2013 10:36:58 PM org.apache.solr.servlet.SolrDispatchFilter handleAdminRequest
INFO: [admin] webapp=null path=/admin/cores params=indexInfo=false&wt=json status=0 QTime=1 

【问题讨论】:

您指出的 Solr 端点是什么?是否启动并运行? @SrikanthVenugopalan 我已将我的 sunspot.yml 添加到问题的底部。你指的是这个吗?抱歉,如果没有,我真的很喜欢 Solr。 太棒了.. 我假设您可以从出现此错误的服务器上点击http://localhost:8983 @SrikanthVenugopalan - 我之前可以在这里找到管理员:localhost:8983/solr/#/development - 但我将我的 solr gem 更新到 2.1.0,现在收到以下错误:screencast.com/t/rtXpIBbRisPq。有什么想法吗? 嗯 - 告诉我你的 Solr 实例没有启动,因为 SolrConfig 中的错误。你能看看你的 Solr (Jetty) 日志吗?它应该有一个堆栈跟踪 【参考方案1】:

我在从 2.0.0 升级到 sunspot 2.1.0 时遇到了同样的问题。

我通过在development: 块上将以下行添加到sunspot.yml(在我的rails 应用程序中的配置下)解决了这个问题(testproduction 可能需要一个)

    solr_home: solr

所以我的 SOLR 安装在 rails-app-dir/solr 下,配置在 conf 下。

【讨论】:

此时此刻,你是我的英雄。这修复了我的开发环境中的 404 错误!我将尽快进行暂存,以在该环境中测试相同的添加。太感谢了。在此之前,我的搜索实际上也被破坏了——由于某种原因,位置搜索不起作用。如果我发布一个关于它的 SO 条目,我想知道你是否不介意找我? :) 可悲的是,这并不能在生产中解决它:(关于如何让它工作的任何想法?此时我将你提到的用于开发的相同修复添加到生产块中。你知道吗需要为生产提供的具体参考? 好吧 - 基本上这需要指向您的 SOLR 文件所在的位置。使用locatefind shell 命令来解决这个问题。您基本上是在寻找数据/生产目录。寻找sunspot-solr-production.pid 的好人选 刚刚注意到有关铁轨的一些信息 - 太阳黑子数据文件。似乎 2.1.0 将数据存储在 gems - 目录下。我认为在 2.0.0 上它在 rails app solr/ 下。 虽然这并不能完全解决我的问题,但它让我知道从 2.0 迁移到 2.1 是我的问题。将 Gem 回滚到 2.0 并能够解决我的问题。现在我只需要弄清楚如何成功迁移到 2.1。【参考方案2】:

@Marko Taponen 的解决方案为我工作了一段时间,但现在我回来了,因为这个问题再次出现在我的 rpsec/capybara 测试中。

这是为我解决的问题:

在命令行上:

bundle exec rake sunspot:solr:stop

完成此操作后,我再次运行测试,它成功了。!

【讨论】:

【参考方案3】:

我一直在寻找这个问题的答案,并了解 SOLR 管理页面为什么会崩溃。这是将 sunspot solr 从 2.0.0 升级到 2.1.0 时针对此问题的解决方案:

将此条目添加到 sunspot.yml 的开发部分:solr_home: solr 就像以下示例一样...

development:
  solr:
    hostname: localhost
    port: 8982
    log_level: INFO
    path: /solr/development
    solr_home: solr

【讨论】:

【参考方案4】:

这些是您应该遵循的终端命令来解决您的问题:

    ps aux | grep solr 获取 solr 进程 ID sudo kill &lt;ID&gt;,&lt;ID&gt;是你从1中找到的ID rm -r &lt;path/to/solr&gt;,删除项目中的 solr 目录以删除所有以前的索引 RAILS_ENV=production bundle exec rake sunspot:solr:start 将路径更改为 /solr/defaultconfig/sunspot.yml
    development:
      solr:
        hostname: localhost
        port: 8982
        log_level: INFO
        path: /solr/default
    
    RAILS_ENV=production bundle exec rake sunspot:solr:reindex

砰!问题解决了!我希望。

【讨论】:

这完全有效!我明天必须演示我的应用程序,在我找到你的答案之前它完全坏了!! 为什么我不能多次为同一个答案投票???谢谢,谢谢,谢谢!!! 工作就像一个魅力!我猜关键是将索引名称更改为/solr/default 任何想法如何使用自定义索引名称? 谢谢!解决方案是 /solr/default 部分:) 在我的情况下,我必须设置路径:/sorl,没有默认或开发【参考方案5】:

有人检查了您的项目的 ./solr 目录吗?

如果是这样,请将其删除,运行 rails g sunspot_rails:install 然后再次启动您的服务器。

这个已经咬了我两次了。

【讨论】:

【参考方案6】:

还要检查是否从您的 gem 文件或应用程序根目录中的 solr 目录加载了 schema.xml!您最终可能会多次更改 schema.xml,但加载的文件可能是错误的。

【讨论】:

【参考方案7】:
development:
  solr:
    hostname: localhost
    port: 8982
    log_level: INFO
    path: /solr
  auto_index_callback: after_commit
  auto_remove_callback: after_commit

【讨论】:

以上是关于Rails 应用程序:Solr 在执行搜索时抛出 RSolr::Error::Http - 404 Not Found的主要内容,如果未能解决你的问题,请参考以下文章

Gmaps4rails - 当 JSON == "[]" 时,地图在第一次加载时抛出 JS 错误

当搜索没有结果时抛出一个弹出窗口

rails solr search 限制总搜索结果/获得固定数量的结果

执行查询时抛出异常

尝试访问损坏的图片 url 时抛出内部服务器错误 500 而不是 404

Sunspot Solr Rails - 使用“with”搜索多个模型