Class: Ferret::Field

### Home Classes Methods

### In Files

- lib/ferret/document.rb

### Parent

Array

### Methods

- ::new
- #+
- #==
- #eql?
- #to_s

### Included Modules

- Ferret::BoostMixin

### 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::Field

A Field is a section of a Document. A Field is basically an array with a boost attribute. It also provides pretty printing of the field with the to_s method.

### Boost

The boost attribute makes a field more important in the index. That is, you can increase the score of a match for queries that match terms in a boosted field. You may, for example, want to boost a title field so that matches that match in the :title field score more highly than matches that match in the :contents field.

Note: If you'd like to use boosted fields without having to use the Field class you can just include the BoostMixin in the Array class. See BoostMixin.

### Public Class Methods

new(data = [], boost = 1.0) click to toggle source

Create a new Field object. You can pass data to the field as either a string;

    f = Field.new("This is the fields data")

or as an array of strings;

    f = Field.new(["this", "is", "an", "array", "of", "field", "data"])

Of course Fields can also be boosted;

    f = Field.new("field data", 1000.0)

    # File lib/ferret/document.rb, line 106
    def initialize(data = [], boost = 1.0)
      @boost = boost
      if data.is_a? Array
        data.each {|v| self << v}
      else
        self << data.to_s
      end
    end

### Public Instance Methods

+(o) click to toggle source

    # File lib/ferret/document.rb, line 120
    def +(o)
      return Field.new(super(o), self.boost)
    end

==(o) click to toggle source
Alias for: eql?
eql?(o) click to toggle source

    # File lib/ferret/document.rb, line 115
    def eql?(o)
      return (o.is_a? Field and (o.boost == @boost) and super(o))
    end

Also aliased as: ==
to_s() click to toggle source

    # File lib/ferret/document.rb, line 124
    def to_s
      buf = %{["#{self.join('", "')}"]}
      buf << "^#@boost" if @boost != 1.0
      return buf
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.