#149 ✓resolved
Jason Ronallo

:as option should accept array without setting the :multiple option

Reported by Jason Ronallo | November 10th, 2010 @ 04:56 PM | in 1.2

In Sunspot 1.2rc4 I was using the following:

searchable do
string :subject_facet, :as => :subject_facet do |r|

r.subjects.map{|s| s.subject}

end end
It fails for subject_facet with the error
"subject_facet is not a multiple-value field, so it cannot index values".

When the :as option is specified it should not require the :multiple option to index an array. Someone using the :as option will have to know their own Solr schema enough to know
whether the field is multiValued or not. So either a single value or an Array ought to be accepted.

See this thread for full background:

I've created a branch which saves an :as attribute for each Sunspot::Field, since when the :as value is assigned to indexed_name it is deleted. The :as attribute allows us to check for the presence of the as option and handle things differently.

The only difference I've implemented is that #to_indexed should not reject an Array if the :multiple option is not set.

You can see my branch for this bugfix here:

See the commit here:

I'm not familiar enough with the code or the options to know whether this :as checking needs to happen anywhere else. For instance in AttributeField#indexed_name should each piece check for that :as option? and not change the indexed_name even if the :multiple option is set?

Comments and changes to this ticket

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.

New-ticket Create new ticket

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


Referenced by