Sunspot reindex Caused by: java.lang.NullPointerException

230 views
Skip to first unread message

baw...@gmail.com

unread,
Jan 26, 2016, 8:02:40 AM1/26/16
to Sunspot

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:

Skipping progress bar: for progress reporting, add gem 'progress_bar' to your Gemfile
Error - RSolr::Error::Http - 500 Internal Server Error - retrying...
Error - RSolr::Error::Http - 500 Internal Server Error - ignoring...
rake aborted!
RSolr::Error::Http: RSolr::Error::Http - 400 Bad Request
Error: {'responseHeader'=>{'status'=>400,'QTime'=>2},'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 name=\"id_i\">1</field><field name=\"shipping_method_s\">actual_cost_shipping</field><field name=\"condition_s\">brand_new</field><field name=\"price_e\">12.0</field><field name=\"category_ids_im\">28</field><field name=\"category_ids_im\">4</field><field name=\"created_at_d\">2016-01-05T05:42:13Z</field><field name=\"location_ll\">37.5641,-122.004</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 name=\"id_i\">2</field><field name=\"shipping_method_s\">fixed_cost_shipping</field><field name=\"condition_s\">used</field><field name=\"price_e\">199999.0</field><field name=\"category_ids_im\">3</field><field name=\"category_ids_im\">4</field><field name=\"created_at_d\">2016-01-15T05:07:39Z</field><field name=\"location_ll\">37.5641,-122.004</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 name=\"id_i\">3</field><field name=\"shipping_method_s\">free_shipping</field><field name=\"condition_s\">refurbished</field><field name=\"price_e\">123.0</field><field name=\"category_ids_im\">2</field><field name=\"category_ids_im\">1</field><field name=\"created_at_d\">2016-01-17T20:27:55Z</field><field name=\"location_ll\">37.5641,-122.004</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)>'
Tasks: TOP => sunspot:reindex
(See full trace by running task with --trace)



After trying to use Solr Admin, I see that the problem is caused by :java.lang.NullPointerException

org.apache.solr.common.SolrException: Exception writing document id Product 1 to the index; possible analysis error.
at org.apache.solr.update.DirectUpdateHandler2.addDoc(DirectUpdateHandler2.java:167)
at org.apache.solr.update.processor.RunUpdateProcessor.processAdd(RunUpdateProcessorFactory.java:69)
at org.apache.solr.update.processor.UpdateRequestProcessor.processAdd(UpdateRequestProcessor.java:51)
at org.apache.solr.update.processor.DistributedUpdateProcessor.doLocalAdd(DistributedUpdateProcessor.java:955)
at org.apache.solr.update.processor.DistributedUpdateProcessor.versionAdd(DistributedUpdateProcessor.java:1110)
at org.apache.solr.update.processor.DistributedUpdateProcessor.processAdd(DistributedUpdateProcessor.java:706)
at org.apache.solr.update.processor.LogUpdateProcessor.processAdd(LogUpdateProcessorFactory.java:104)
at org.apache.solr.handler.loader.XMLLoader.processUpdate(XMLLoader.java:250)
at org.apache.solr.handler.loader.XMLLoader.load(XMLLoader.java:177)
at org.apache.solr.handler.UpdateRequestHandler$1.load(UpdateRequestHandler.java:98)
at org.apache.solr.handler.ContentStreamHandlerBase.handleRequestBody(ContentStreamHandlerBase.java:74)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:143)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:2068)
at org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:669)
at org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:462)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:214)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:179)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:499)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at org.apache.solr.update.DocumentBuilder.toDocument(DocumentBuilder.java:101)
at org.apache.solr.update.AddUpdateCommand.getLuceneDocument(AddUpdateCommand.java:83)
at org.apache.solr.update.DirectUpdateHandler2.addDoc0(DirectUpdateHandler2.java:237) 
 at org.apache.solr.update.DirectUpdateHandler2.addDoc(DirectUpdateHandler2.java:163) 


I'm a newbie to solr and don't know how to debug Java. Please help with a hint to solve this issue.
My model:

class Product
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
    double :price 
    integer :category_ids, :multiple => true
    time :created_at, :updated_at
    latlon(:location) { Sunspot::Util::Coordinates.new(latitude, longitude) }
  end 
...


Reply all
Reply to author
Forward
0 new messages