Sunspot error 400 Bad Request при переиндексации

ruby-on-rails solr full-text-search sunspot

827 просмотра

1 ответ

Я использую sunspot / solr для создания полнотекстового поиска для моего приложения rails. Я был в состоянии запустить bundle exec rake sunspot: reindex для первой пары раз, но затем я получил эту ошибку:

RSolr::Error::Http: RSolr::Error::Http - 400 Bad Request
Error: {'responseHeader'=>{'status'=>400,'QTime'=>1},'error'=>{'msg'=>'Exception writing document id Product 1 to the index; possible analysis error.','code'=>400}}

URI: http://localhost:8982/solr/development/update?wt=ruby
Request Headers: {"Content-Type"=>"text/xml"}
Request Data: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><add><doc><field name=\"id\">Product 1</field><field name=\"type\">Product</field><field name=\"type\">ActiveRecord::Base</field><field name=\"class_name\">Product</field><field boost=\"5\" name=\"code_textp\">Macbook pro 123</field><field name=\"code_textp\">&lt;p&gt;hahahahahhhahahahahhhahahahahhhahahahahhhahahahahhhahahahahhhahahahahhhahahahahh&lt;/p&gt;</field></doc><doc><field name=\"id\">Product 2</field><field name=\"type\">Product</field><field name=\"type\">ActiveRecord::Base</field><field name=\"class_name\">Product</field><field boost=\"5\" name=\"code_textp\">test product</field><field name=\"code_textp\">&lt;p&gt;dfdsfsdfdsfsfsdfsdfdsf&lt;/p&gt;</field></doc><doc><field name=\"id\">Product 3</field><field name=\"type\">Product</field><field name=\"type\">ActiveRecord::Base</field><field name=\"class_name\">Product</field><field boost=\"5\" name=\"code_textp\">Macbook used</field><field name=\"code_textp\">&lt;p&gt;it is refurebishedit is refurebishedit is refurebishedit is refurebishedit is refurebishedit is refurebishedit is refurebished&lt;/p&gt;</field></doc></add>"

Backtrace: /Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/rsolr-1.0.13/lib/rsolr/client.rb:284:in `adapt_response'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/rsolr-1.0.13/lib/rsolr/client.rb:190:in `execute'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/rsolr-1.0.13/lib/rsolr/client.rb:176:in `send_and_receive'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot_rails-2.2.4/lib/sunspot/rails/solr_instrumentation.rb:16:in `block in send_and_receive_with_as_instrumentation'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/activesupport-4.2.4/lib/active_support/notifications.rb:164:in `block in instrument'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/activesupport-4.2.4/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/activesupport-4.2.4/lib/active_support/notifications.rb:164:in `instrument'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot_rails-2.2.4/lib/sunspot/rails/solr_instrumentation.rb:15:in `send_and_receive_with_as_instrumentation'
(eval):2:in `post'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/rsolr-1.0.13/lib/rsolr/client.rb:82:in `update'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/rsolr-1.0.13/lib/rsolr/client.rb:102:in `add'/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/rsolr-1.0.13/lib/rsolr/client.rb:284:in `adapt_response'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/rsolr-1.0.13/lib/rsolr/client.rb:190:in `execute'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/rsolr-1.0.13/lib/rsolr/client.rb:176:in `send_and_receive'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot_rails-2.2.4/lib/sunspot/rails/solr_instrumentation.rb:16:in `block in send_and_receive_with_as_instrumentation'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/activesupport-4.2.4/lib/active_support/notifications.rb:164:in `block in instrument'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/activesupport-4.2.4/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/activesupport-4.2.4/lib/active_support/notifications.rb:164:in `instrument'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot_rails-2.2.4/lib/sunspot/rails/solr_instrumentation.rb:15:in `send_and_receive_with_as_instrumentation'
(eval):2:in `post'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/rsolr-1.0.13/lib/rsolr/client.rb:82:in `update'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/rsolr-1.0.13/lib/rsolr/client.rb:102:in `add'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot-2.2.4/lib/sunspot/indexer.rb:127:in `add_documents'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot-2.2.4/lib/sunspot/indexer.rb:134:in `add_batch_documents'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot-2.2.4/lib/sunspot/indexer.rb:26:in `add'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot-2.2.4/lib/sunspot/session.rb:91:in `index'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot-2.2.4/lib/sunspot/session_proxy/abstract_session_proxy.rb:11:in `index'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot-2.2.4/lib/sunspot/session_proxy/retry_5xx_session_proxy.rb:17:in `method_missing'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot-2.2.4/lib/sunspot/session_proxy/abstract_session_proxy.rb:11:in `index'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot-2.2.4/lib/sunspot.rb:184:in `index'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot_rails-2.2.4/lib/sunspot/rails/searchable.rb:264:in `block (2 levels) in solr_index'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot_rails-2.2.4/lib/sunspot/rails/searchable.rb:405:in `solr_benchmark'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot_rails-2.2.4/lib/sunspot/rails/searchable.rb:263:in `block in solr_index'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.4/lib/active_record/relation/batches.rb:124:in `find_in_batches'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot_rails-2.2.4/lib/sunspot/rails/searchable.rb:261:in `solr_index'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot_rails-2.2.4/lib/sunspot/rails/searchable.rb:210:in `solr_reindex'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot_rails-2.2.4/lib/sunspot/rails/tasks.rb:60:in `block (4 levels) in <top (required)>'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot-2.2.4/lib/sunspot/class_set.rb:16:in `each'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot-2.2.4/lib/sunspot/class_set.rb:16:in `each'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot_rails-2.2.4/lib/sunspot/rails/tasks.rb:59:in `block (3 levels) in <top (required)>'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot_rails-2.2.4/lib/sunspot/rails/tasks.rb:71:in `with_session'
/Users/LouisHoang/.rvm/gems/ruby-2.2.3/gems/sunspot_rails-2.2.4/lib/sunspot/rails/tasks.rb:19:in `block (2 levels) in <top (required)>'

Единственный способ исправить эту ошибку - переустановить гем. Интересно, встречал ли кто-нибудь такую ​​же проблему?

Вот моя модель:

class Product < ActiveRecord::Base
searchable do
    text :name, :as => :code_textp, :boost => 5
    text :description, :as => :code_textp
    integer :id, :seller_id, :stock_quantity
    string :shipping_method
    string :condition, :location, :slug, :status, :city, :state, :product_image
    double :price 
    integer :category_ids, :multiple => true
    time :created_at, :updated_at
    latlon(:location) { Sunspot::Util::Coordinates.new(latitude, longitude) }
  end
...

Я использую настройки по умолчанию для schema.xml, и solr работает при посещении http: // localhost: 8982 /

Спасибо за помощь.

Автор: Louis Источник Размещён: 16.10.2019 09:35

Ответы (1)


4 плюса

После нескольких часов, потянув за волосы, я понял, что проблема действительно проста. Каждый раз, когда я заканчивал работать, я не запускал bundle exec sunspot: solr: stop для выключения сервера solr, поэтому файл журнала не обновляется с идентификатором pid и процесса. Заключение: всегда запускайте bundle exec sunspot: solr: stop перед изменением schema.xml или переводите ноутбук в спящий режим. Затем, bundle exec sunspot: solr: начать работать дальше. Я надеюсь, что это поможет решить новичка, как и я.

Автор: Louis Размещён: 27.01.2016 04:52
Вопросы из категории :
32x32