Methods

Class Index [+]

Quicksearch

Ferret::FieldSymbolMethods

The FieldSymbolMethods module contains the methods that are added to both the Symbol class and the FieldSymbol class. These methods allow you to set the type easily set the type of a field by calling a method on a symbol.

Right now this is only useful for Sorting and grouping, but some day Ferret may have typed fields, in which case these this methods will come in handy.

The available types are specified in Ferret::FIELD_TYPES.

Examples

  index.search(query, :sort => :title.string.desc)

  index.search(query, :sort => [:price.float, :count.integer.desc])
  
  index.search(query, :group_by => :catalogue.string)

Note

If you set the field type multiple times, the last type specified will be the type used. For example;

  puts :title.integer.float.byte.string.type.inspect # => :string

Calling # twice will set desc? to false

  puts :title.desc?           # => false
  puts :title.desc.desc?      # => true
  puts :title.desc.desc.desc? # => false

Public Instance Methods

desc() click to toggle source

Set a field to be a descending field. This only makes sense in sort specifications.

    # File lib/ferret/field_symbol.rb, line 51
51:     def desc
52:       fsym = FieldSymbol.new(self, respond_to?(:desc?) ? !desc? : true)
53:       fsym.type = type if respond_to? :type
54:       fsym
55:     end
desc?() click to toggle source

Return whether or not this field should be a descending field

    # File lib/ferret/field_symbol.rb, line 58
58:     def desc?
59:       @desc == true
60:     end
type() click to toggle source

Return the type of this field

    # File lib/ferret/field_symbol.rb, line 63
63:     def type
64:       @type || nil
65:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.