简体   繁体   中英

How to index a text(large data) field using sunspot solr

In rails 4.0.2, I am using sunspot solr as a search engine. Here, there is one text field which contains large text(data) with special characters.

While running a reindex command, I am getting an error like Backtrace: /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rsolr-1.0.10/lib/rsolr/client.rb:283:in 'adapt_response'...

In model,

searchable do
  string   :cv_content
end

Using Gems are,

sunspot (2.1.1)
sunspot_rails (2.1.1)
sunspot_solr (2.1.1)

How can I solve reindex issue?

Full Error:

Backtrace: /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rsolr-1.0.10/lib/rsolr/client.rb:283:in adapt_response' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rsolr-1.0.10/lib/rsolr/client.rb:190:in execute' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rsolr-1.0.10/lib/rsolr/client.rb:176:in send_and_receive' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot_rails-2.1.1/lib/sunspot/rails/solr_instrumentation.rb:16:in block in send_and_receive_with_as_instrumentation' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.2/lib/active_support/notifications.rb:159:in block in instrument' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.2/lib/active_support/notifications/instrumenter.rb:20:in instrument' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.2/lib/active_support/notifications.rb:159:in instrument' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot_rails-2.1.1/lib/sunspot/rails/solr_instrumentation.rb:15:in send_and_receive_with_as_instrumentation' (eval):2:in post' /home/shruthi /.rvm/gems/ruby-2.1.2/gems/rsolr-1.0.10/lib/rsolr/client.rb:82:in update' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rsolr-1.0.10/lib/rsolr/client.rb:102:in add'/home/shruthi/.rvm/gems/ruby-2.1.2/gems/rsolr-1.0.10/lib/rsolr/client.rb:283:in adapt_response' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rsolr-1.0.10/lib/rsolr/client.rb:190:in execute' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rsolr-1.0.10/lib/rsolr/client.rb:176:in send_and_receive' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot_rails-2.1.1/lib/sunspot/rails/solr_instrumentation.rb:16:in block in send_and_receive_with_as_instrumentation' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.2/lib/active_support/notifications.rb:159:in block in instrument' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.2/lib/active_support/notifications/instrumenter.rb:20:in instrument' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/activesupport-4.0.2/lib/active_support/notifications.rb:159:in instrument' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot_rails-2.1.1/lib/sunspot/rails/solr_instrumentation.rb:15:in instrument' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot_rails-2.1.1/lib/sunspot/rails/solr_instrumentation.rb:15:in send_and_receive_with_as_instrumentation' (eval):2:in post' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rsolr-1.0.10/lib/rsolr/client.rb:82:in update' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rsolr-1.0.10/lib/rsolr/client.rb:102:in add' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot-2.1.1/lib/sunspot/indexer.rb:107:in add_documents' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot-2.1.1/lib/sunspot/indexer.rb:30:in add' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot-2.1.1/lib/sunspot/session.rb:91:in index' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot-2.1.1/lib/sunspot/session_proxy/abstract_session_proxy.rb:11:in index' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot-2.1.1/lib/sunspot/session_proxy/retry_5xx_session_proxy.rb:17:in method_missing' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot-2.1.1/lib/sunspot/session_proxy/abstract_session_proxy.rb:11:in index' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot-2.1.1/lib/sunspot.rb:184:in index' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot-2.1.1/lib/sunspot.rb:184:in index' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot_rails-2.1.1/lib/sunspot/rails/searchable.rb:257:in block (2 levels) in solr_index' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot_rails-2.1.1/lib/sunspot/rails/searchable.rb:360:in solr_benchmark' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot_rails-2.1.1/lib/sunspot/rails/searchable.rb:256:in block in solr_index' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/activerecord-4.0.2/lib/active_record/relation/batches.rb:75:in find_in_batches' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/activerecord-deprecated_finders-1.0.3/lib/active_record/deprecated_finders/relation.rb:70:in find_in_batches' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot_rails-2.1.1/lib/sunspot/rails/searchable.rb:254:in solr_index' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot_rails-2.1.1/lib/sunspot/rails/searchable.rb:203:in solr_reindex' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot_rails-2.1.1/lib/sunspot/rails/tasks.rb:57:in block (4 level s) in ' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot-2.1.1/lib/sunspot/class_set.rb:16:in each' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot-2.1.1/lib/sunspot/class_set.rb:16:in each' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot_rails-2.1.1/lib/sunspot/rails/tasks.rb:56:in block (3 levels) in <top (required)>' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot_rails-2.1.1/lib/sunspot/rails/tasks.rb:68:in with_session' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/sunspot_rails-2.1.1/lib/sunspot/rails/tasks.rb:19:in block (2 levels) in <top (required)>' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:240:in call' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:240:in block in execute' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:235:in each' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:235:in execute' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:179:in block in invoke_with_c all_chain' /home/shruthi/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in mon_synchronize' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:172:in invoke_with_call_chain' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/task.rb:165:in invoke' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:150:in invoke_task' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:106:in block (2 levels) in top_level' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:106:in each' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:106:in block in top_level' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:115:in run_with_threads' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:100:in top_level' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:78:in block in run' /home/shruthi/.rvm/gems/r uby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:176:in standard_exception_handling' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/lib/rake/application.rb:75:in run' /home/shruthi/.rvm/gems/ruby-2.1.2/gems/rake-10.3.2/bin/rake:33:in <top (required)>' /home/shruthi/.rvm/gems/ruby-2.1.2/bin/rake:23:in load' /home/shruthi/.rvm/gems/ruby-2.1.2/bin/rake:23:in <main>' /home/shruthi/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in eval' /home/shruthi/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in <main>' Tasks: TOP => sunspot:reindex

Recommended from ticket solr, sunspot, bad request, illegal character I created config/initializers/sunspot.rb with the suggested code and it did the trick.

Here's the issue mentioned in that ticket where the code was first suggested. https://github.com/sunspot/sunspot/issues/570

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM