Reputation: 103
I'm using sunspot/solr to build a full text search for my rails app. I was able to run bundle exec rake sunspot:reindex for the first couple times but then I received this error:
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\"><p>hahahahahhhahahahahhhahahahahhhahahahahhhahahahahhhahahahahhhahahahahhhahahahahh</p></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\"><p>dfdsfsdfdsfsfsdfsdfdsf</p></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\"><p>it is refurebishedit is refurebishedit is refurebishedit is refurebishedit is refurebishedit is refurebishedit is refurebished</p></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)>'
The only way that I can fix this error is to reinstall the gem. I wonder if someone met the same problem?
Here is my model:
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
...
I use default setting for schema.xml and solr is running when visiting http://localhost:8982/
Thanks for helping.
Upvotes: 0
Views: 1179
Reputation: 103
After hours pulling hair I found out the issue is really simple.
Every time I finished working I didn't run bundle exec sunspot:solr:stop to shut down solr server, so the log file is not updated with the pid and process id.
Conclusion, always run
bundle exec rake sunspot:solr:stop
before changing schema.xml or put laptop to sleep. Then,
bundle exec rake sunspot:solr:start
to continue working.
I hope this will help solr newbie just like me.
Upvotes: 5