it-roy-ru.com

Приложение Rails: Solr throwing RSolr :: Error :: Http - 404 Not Found при выполнении поиска

Очень потерян, так как я не внес никаких изменений в свой поиск, который всегда работал, но каким-то образом у меня был перерыв. Будучи относительно новым для 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"=>""}

Sunspot.yml

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

солнечные пятна-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 
31
justinraczak

Я столкнулся с той же проблемой при обновлении до версии 2.1.0 с 2.0.0.

Я решил эту проблему, добавив следующую строку в sunspot.yml (в разделе config в моем приложении Rails) в блоке development: (возможно, он нужен для test и production)

    solr_home: solr

Так что моя установка SOLR находится под Rails-app-dir/solr, а конфигурация там под conf.

57
Marko Taponen

Это команды терминала, которые вы должны выполнить, чтобы решить свои проблемы:

  1. ps aux | grep solrчтобы получить идентификатор процесса solr
  2. Sudo kill <ID>, <ID>это идентификатор, который вы нашли из 1
  3. rm -r <path/to/solr>, удалите директорию solr внутри вашего проекта, чтобы удалить все предыдущие индексы
  4. Rails_ENV=production bundle exec rake sunspot:solr:start
  5. Измените путь на/solr/defaultinsideconfig/sunspot.yml
    development:
      solr:
        hostname: localhost
        port: 8982
        log_level: INFO
        path: /solr/default
    
  6. Rails_ENV=production bundle exec rake sunspot:solr:reindex

Бам! Проблемы решены! Я надеюсь.

35
vutran

Я всегда искал ответ на этот вопрос и понимал, почему страница администратора 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
5
Ehud Pardo

Кто-нибудь проверял в каталоге ./solr ваш проект?

Если это так, удалите его, запустите Rails g sunspot_Rails: install и затем снова запустите свой сервер.

Этот укусил меня дважды.

3
xdotcommer

Решение @Marko Taponen у меня работало некоторое время, но теперь я вернулся, потому что эта проблема снова подняла свою уродливую голову, на этот раз в моих тестах rpsec/capybara. 

Вот что исправило это для меня:

В командной строке:

bundle exec rake sunspot:solr:stop

После этого я снова запустил тесты, и это сработало!

2
nfriend21
development:
  solr:
    hostname: localhost
    port: 8982
    log_level: INFO
    path: /solr
  auto_index_callback: after_commit
  auto_remove_callback: after_commit
1
fabro

Также проверьте, загружен ли schema.xml из вашего файла gem или из вашего каталога solr в корне приложения! Вы можете несколько раз изменить schema.xml, но это будет неправильный загруженный файл. 

0
Nesha Zoric