Class: Sunspot::AttributeField

Inherits:
Field
  • Object
show all
Defined in:
lib/sunspot/field.rb

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

#boost, #name, #reference, #type

Instance Method Summary collapse

Methods inherited from Field

#cast, #eql?, #hash, #more_like_this?, #multiple?, #to_indexed

Constructor Details

#initialize(name, type, options = {}) ⇒ AttributeField

:nodoc:

Raises:

  • (ArgumentError)


136
137
138
139
140
141
142
143
144
145
146
# File 'lib/sunspot/field.rb', line 136

def initialize(name, type, options = {})
  super(name, type, options)
  @multiple = !!options.delete(:multiple)
  @reference =
    if (reference = options.delete(:references)).respond_to?(:name)
      reference.name
    elsif reference.respond_to?(:to_sym)
      reference.to_sym
    end
  raise ArgumentError, "Unknown field option #{options.keys.first.inspect} provided for field #{name.inspect}" unless options.empty?
end

Instance Method Details

#indexed_nameObject

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



156
157
158
# File 'lib/sunspot/field.rb', line 156

def indexed_name
  "#{super}#{'m' if @multiple}#{'s' if @stored}#{'v' if more_like_this?}"
end