### Home Classes Methods

### In Files

- lib/ferret/field_symbol.rb

### Methods

- #desc
- #desc?
- #type

### Files

- MIT-LICENSE
- README
- TODO
- TUTORIAL

### Class/Module Index

Quicksearch

- Ferret
- Ferret::BlankSlate
- Ferret::BoostMixin
- Ferret::Browser
- Ferret::Browser::Controller
- Ferret::Browser::Delegator
- Ferret::Browser::DocumentController
- Ferret::Browser::ErrorController
- Ferret::Browser::HelpController
- Ferret::Browser::HomeController
- Ferret::Browser::TermController
- Ferret::Browser::TermVectorController
- Ferret::Browser::ViewHelper
- Ferret::Document
- Ferret::Field
- Ferret::FieldSymbol
- Ferret::FieldSymbolMethods
- Ferret::FileNotFoundError
- Ferret::Index
- Ferret::Index::FieldInfo
- Ferret::Index::FieldInfos
- Ferret::Index::Index
- Ferret::Index::IndexReader
- Ferret::Index::IndexWriter
- Ferret::Index::LazyDoc
- Ferret::Index::LazyDoc::LazyDocData
- Ferret::Index::TermDocEnum
- Ferret::Index::TermEnum
- Ferret::Index::TermVector
- Ferret::Index::TermVector::TVOffsets
- Ferret::Index::TermVector::TVTerm
- Ferret::ParseError
- Ferret::QueryParser
- Ferret::QueryParser::QueryParseException
- Ferret::Search
- Ferret::Search::BooleanQuery
- Ferret::Search::BooleanQuery::BooleanClause
- Ferret::Search::ConstantScoreQuery
- Ferret::Search::Explanation
- Ferret::Search::Filter
- Ferret::Search::FilteredQuery
- Ferret::Search::FuzzyQuery
- Ferret::Search::Hit
- Ferret::Search::MatchAllQuery
- Ferret::Search::MultiSearcher
- Ferret::Search::MultiTermQuery
- Ferret::Search::PhraseQuery
- Ferret::Search::PrefixQuery
- Ferret::Search::Query
- Ferret::Search::QueryFilter
- Ferret::Search::RangeFilter
- Ferret::Search::RangeQuery
- Ferret::Search::Searcher
- Ferret::Search::Sort
- Ferret::Search::SortField
- Ferret::Search::Spans
- Ferret::Search::Spans::SpanFirstQuery
- Ferret::Search::Spans::SpanMultiTermQuery
- Ferret::Search::Spans::SpanNearQuery
- Ferret::Search::Spans::SpanNotQuery
- Ferret::Search::Spans::SpanOrQuery
- Ferret::Search::Spans::SpanPrefixQuery
- Ferret::Search::Spans::SpanTermQuery
- Ferret::Search::TermQuery
- Ferret::Search::TopDocs
- Ferret::Search::TypedRangeFilter
- Ferret::Search::TypedRangeQuery
- Ferret::Search::WildcardQuery
- Ferret::StateError
- Ferret::Store
- Ferret::Store::Directory
- Ferret::Store::FSDirectory
- Ferret::Store::Lock
- Ferret::Store::Lock::LockError
- Ferret::Store::RAMDirectory
- WEBrick
- WEBrick::FerretBrowserHandler
- Date
- DateTime
- FileUtils
- Float
- Integer
- String
- Symbol
- Time

No matching classes.

# 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 desc 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 58
    def desc
      fsym = FieldSymbol.new(self, respond_to?(:desc?) ? !desc? : true)
      fsym.type = type if respond_to? :type
      fsym
    end

desc?() click to toggle source

Return whether or not this field should be a descending field

    # File lib/ferret/field_symbol.rb, line 65
    def desc?
      @desc == true
    end

type() click to toggle source

Return the type of this field

    # File lib/ferret/field_symbol.rb, line 70
    def type
      @type || nil
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.