Retrieving multiple stored integer fields
Reported by Robert Zotter | April 19th, 2010 @ 09:48 PM | in 1.2
Similar to ticket #110
class Item
...
integer :categories,
:references => Category,
:using => :category_ids,
:multiple => true,
:stored => true
...
end
>> search = Sunspot.search(Item) { keywords "foo" }
>> search.hits.first.stored(:categories)
NoMethodError: undefined method `to_i' for [120000, 127000, 127010, 127011]:Array
from /Users/rob/workspace/ioffer/vendor/plugins/sunspot-1.1.0/lib/sunspot/type.rb:148:in `cast'
from /Users/rob/workspace/ioffer/vendor/plugins/sunspot-1.1.0/lib/sunspot/field.rb:56:in `cast'
from /Users/rob/workspace/ioffer/vendor/plugins/sunspot-1.1.0/lib/sunspot/search/hit.rb:129:in `stored_value'
from /Users/rob/workspace/ioffer/vendor/plugins/sunspot-1.1.0/lib/sunspot/search/hit.rb:127:in `each'
from /Users/rob/workspace/ioffer/vendor/plugins/sunspot-1.1.0/lib/sunspot/search/hit.rb:127:in `stored_value'
from /Users/rob/workspace/ioffer/vendor/plugins/sunspot-1.1.0/lib/sunspot/search/hit.rb:85:in `stored'
from (irb):27
>> search.hits.first.instance_variable_get(:@stored_values)
>> {"categories_ims"=>[120000, 127000, 127010, 127011]}
Comments and changes to this ticket
-

Robert Zotter April 19th, 2010 @ 10:03 PM
Came up with a quick workaround... this will actually fix ticket #110 also
module Sunspot module Search class Hit ... def stored_value(field_name, dynamic_field_name) setup.stored_fields(field_name, dynamic_field_name).each do |field| if value = @stored_values[field.indexed_name] return field.multiple? ? value.collect { |v| field.cast(v.to_s) } : field.cast(value.to_s) end end nil end end end end -

mat July 14th, 2010 @ 11:24 AM
- Milestone set to Bugs
- Milestone order changed from 0 to 0
-

mat December 27th, 2010 @ 02:42 PM
- Milestone changed from Bugs to 1.2
- Milestone order changed from 18 to 0
-

mat December 27th, 2010 @ 04:32 PM
- State changed from new to resolved
- Milestone order changed from 1 to 0
(from [cf00a3f18e1cfc97de5c99f4db90c372938c574d]) Correctly cast and return stored values for multi-valued fields
[#111 state:resolved] https://github.com/outoftime/sunspot/commit/cf00a3f18e1cfc97de5c99f...
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Awesome Solr interaction for Ruby
People watching this ticket
Tags
Referenced by
-
#111 Retrieving multiple stored integer fields
[#111 state:resolved]
https://github.com/outoftime/sunsp...