Created
February 2, 2018 10:55
-
-
Save dilkhush/cc7e5b8adea0bf7f043787922de1336c to your computer and use it in GitHub Desktop.
Solr Atomic update issue with multiple true fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/company.rb | |
class Company < ActiveRecord::Base | |
searchable do | |
string :locations, multiple: true, stored: true do | |
["Location1", "Location2", "Location3"] | |
end | |
end | |
end | |
# Using atomic_update | |
company = Company.last | |
company.atomic_update({location: ["Location4", "Location5"]}) | |
This should update the location but it raise an error. bloe are the versions | |
sunspot_solr-2.2.7 | |
sunspot_rails-2.2.7 | |
rails-4.2.10 | |
============= Error Stack ======= | |
2.4.1 :029 > c.atomic_update({location: ["Location4", "Location5"]}) | |
D, [2018-02-02T16:20:30.425951 #19586] DEBUG -- : SOLR Request (6.2ms) [ path=update parameters={} ] | |
RSolr::Error::Http: RSolr::Error::Http - 400 Bad Request | |
Error: {"responseHeader":{"status":400,"QTime":1},"error":{"msg":"Error parsing JSON field value. Unexpected OBJECT_START","code":400}} | |
URI: http://localhost:8983/solr/development/update?wt=json | |
Request Headers: {"Content-Type"=>"application/json"} | |
Request Data: "[{\"id\":\"Corporation 17\",\"type\":[\"Corporation\",\"Company\",\"ActiveRecord::Base\"],\"location_sms\":[{\"set\":\"Location4\"},{\"set\":\"Location5\"}]}]" | |
Backtrace: /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/rsolr-2.1.0/lib/rsolr/client.rb:196:in `rescue in execute' | |
/home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/rsolr-2.1.0/lib/rsolr/client.rb:186:in `execute' | |
/home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/rsolr-2.1.0/lib/rsolr/client.rb:181:in `send_and_receive' | |
/home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/sunspot_rails-2.2.7/lib/sunspot/rails/solr_instrumentation.rb:16:in `block in send_and_receive_with_as_instrumentation' | |
/home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/activesupport-4.2.10/lib/active_support/notifications.rb:164:in `block in instrument' | |
/home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/activesupport-4.2.10/lib/active_support/notifications/instrumenter.rb:20:in `instrument' | |
/home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/activesupport-4.2.10/lib/active_support/notifications.rb:164:in `instrument' | |
/home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/sunspot_rails-2.2.7/lib/sunspot/rails/solr_instrumentation.rb:15:in `send_and_receive_with_as_instrumentation' | |
(eval):2:in `post' | |
/home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/rsolr-2.1.0/lib/rsolr/client.rb:84:in `update' | |
/home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/rsolr-2.1.0/lib/rsolr/client.rb:103:in `add' | |
from /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/rsolr-2.1.0/lib/rsolr/client.rb:196:in `rescue in execute' | |
from /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/rsolr-2.1.0/lib/rsolr/client.rb:186:in `execute' | |
from /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/rsolr-2.1.0/lib/rsolr/client.rb:181:in `send_and_receive' | |
from /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/sunspot_rails-2.2.7/lib/sunspot/rails/solr_instrumentation.rb:16:in `block in send_and_receive_with_as_instrumentation' | |
from /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/activesupport-4.2.10/lib/active_support/notifications.rb:164:in `block in instrument' | |
from /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/activesupport-4.2.10/lib/active_support/notifications/instrumenter.rb:20:in `instrument' | |
from /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/activesupport-4.2.10/lib/active_support/notifications.rb:164:in `instrument' | |
from /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/sunspot_rails-2.2.7/lib/sunspot/rails/solr_instrumentation.rb:15:in `send_and_receive_with_as_instrumentation' | |
from (eval):2:in `post' | |
from /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/rsolr-2.1.0/lib/rsolr/client.rb:84:in `update' | |
from /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/rsolr-2.1.0/lib/rsolr/client.rb:103:in `add' | |
from /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/sunspot-2.2.7/lib/sunspot/indexer.rb:127:in `add_documents' | |
from /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/sunspot-2.2.7/lib/sunspot/indexer.rb:134:in `add_batch_documents' | |
from /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/sunspot-2.2.7/lib/sunspot/indexer.rb:41:in `add_atomic_update' | |
from /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/sunspot-2.2.7/lib/sunspot/session.rb:107:in `atomic_update' | |
from /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/sunspot-2.2.7/lib/sunspot/session_proxy/abstract_session_proxy.rb:11:in `atomic_update' | |
from /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/sunspot-2.2.7/lib/sunspot.rb:216:in `atomic_update' | |
from /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/sunspot_rails-2.2.7/lib/sunspot/rails/searchable.rb:450:in `solr_atomic_update' | |
from (irb):29 | |
from /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/railties-4.2.10/lib/rails/commands/console.rb:110:in `start' | |
from /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/railties-4.2.10/lib/rails/commands/console.rb:9:in `start' | |
from /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:68:in `console' | |
from /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/railties-4.2.10/lib/rails/commands/commands_tasks.rb:39:in `run_command!' | |
from /home/dilkhush/.rvm/gems/ruby-2.4.1@GF/gems/railties-4.2.10/lib/rails/commands.rb:17:in `<top (required)>' | |
from bin/rails:4:in `require' | |
from bin/rails:4:in `<main>' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment