Class: Sunspot::AttributeField
Overview
AttributeField instances encapsulate non-tokenized attribute data. AttributeFields can have any type except TextType, and can also have a reference (for instantiated facets), optionally allow multiple values (false by default), and can store their values (false by default). All scoping, sorting, and faceting is done with attribute fields.
Instance Attribute Summary
Attributes inherited from Field
#attributes, #name, #reference, #type
Instance Method Summary collapse
-
#indexed_name ⇒ Object
The name of the field as it is indexed in Solr.
-
#initialize(name, type, options = {}) ⇒ AttributeField
constructor
:nodoc:.
Methods inherited from Field
#cast, #multiple?, #to_indexed
Constructor Details
#initialize(name, type, options = {}) ⇒ AttributeField
:nodoc:
108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/sunspot/field.rb', line 108 def initialize(name, type, = {}) super(name, type) @multiple = !!.delete(:multiple) @reference = if (reference = .delete(:references)).respond_to?(:name) reference.name elsif reference.respond_to?(:to_sym) reference.to_sym end @stored = !!.delete(:stored) raise ArgumentError, "Unknown field option #{.keys.first.inspect} provided for field #{name.inspect}" unless .empty? end |
Instance Method Details
#indexed_name ⇒ Object
The name of the field as it is indexed in Solr. The indexed name contains a suffix that contains information about the type as well as whether the field allows multiple values for a document.
Returns
- String
-
The field’s indexed name
129 130 131 |
# File 'lib/sunspot/field.rb', line 129 def indexed_name "#{super}#{'m' if @multiple}#{'s' if @stored}" end |