Class: Sunspot::FulltextField

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

Overview

FulltextField instances represent fields that are indexed as fulltext. These fields are tokenized in the index, and can have boost applied to them. They also always allow multiple values (since the only downside of allowing multiple values is that it prevents the field from being sortable, and sorting on tokenized fields is nonsensical anyway, there is no reason to do otherwise). FulltextField instances always have the type TextType.

Instance Attribute Summary collapse

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, options = {}) ⇒ FulltextField

Returns a new instance of FulltextField.

Raises:

  • (ArgumentError)


115
116
117
118
119
120
121
# File 'lib/sunspot/field.rb', line 115

def initialize(name, options = {})
  super(name, Type::TextType.instance, options)
  @multiple = true
  @boost = options.delete(:boost)
  @default_boost = options.delete(:default_boost)
  raise ArgumentError, "Unknown field option #{options.keys.first.inspect} provided for field #{name.inspect}" unless options.empty?
end

Instance Attribute Details

#default_boostObject (readonly)

:nodoc:



113
114
115
# File 'lib/sunspot/field.rb', line 113

def default_boost
  @default_boost
end

Instance Method Details

#indexed_nameObject



123
124
125
# File 'lib/sunspot/field.rb', line 123

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