Method: Ferret::Document::Field#initialize
- Defined in:
- lib/ferret/document/field.rb
#initialize(name, value, stored = Store::YES, index = Index::UNTOKENIZED, store_term_vector = TermVector::NO, binary = false, boost = 1.0) ⇒ Field
Create a field by specifying its name, value and how it will be saved in the index.
- name
-
The name of the field
- value
-
The string to process
- store
-
Whether value should be stored in the index
- index
-
Whether the field should be indexed, and if so, if it should be tokenized before indexing
- store_term_vector
-
Whether term vector should be stored
* the field is neither stored nor indexed
* the field is not indexed but term_vector is _TermVector::YES_
- binary
-
Whether you want to store binary data in this field. Default is
false
- boost
-
the boost for this field. Default is 1.0. A larger number makes
this field more important.
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/ferret/document/field.rb', line 148 def initialize(name, value, stored = Store::YES, index = Index::UNTOKENIZED, store_term_vector = TermVector::NO, binary = false, boost = 1.0) if (index == Index::NO and stored == Store::NO) raise ArgumentError, "it doesn't make sense to have a field that " + "is neither indexed nor stored" end if (index == Index::NO && store_term_vector != TermVector::NO) raise ArgumentError, "cannot store term vector information for a " + "field that is not indexed" end # The name of the field (e.g., "date", "subject", "title", or "body") @name = name # the one and only data object for all different kind of field values @data = value self.stored = stored self.index = index self.store_term_vector = store_term_vector @binary = binary @boost = boost end |