Save This Page
Home » lucene-2.3.2-src » org.apache » lucene » document » [javadoc | source]
    1   package org.apache.lucene.document;
    2   
    3   /**
    4    * Copyright 2004 The Apache Software Foundation
    5    *
    6    * Licensed under the Apache License, Version 2.0 (the "License");
    7    * you may not use this file except in compliance with the License.
    8    * You may obtain a copy of the License at
    9    *
   10    *     http://www.apache.org/licenses/LICENSE-2.0
   11    *
   12    * Unless required by applicable law or agreed to in writing, software
   13    * distributed under the License is distributed on an "AS IS" BASIS,
   14    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   15    * See the License for the specific language governing permissions and
   16    * limitations under the License.
   17    */
   18   
   19   import java.io.Reader;
   20   import java.io.Serializable;
   21   
   22   import org.apache.lucene.analysis.TokenStream;
   23   
   24   /**
   25    * Synonymous with {@link Field}.
   26    *
   27    **/
   28   public interface Fieldable extends Serializable {
   29     /** Sets the boost factor hits on this field.  This value will be
   30      * multiplied into the score of all hits on this this field of this
   31      * document.
   32      *
   33      * <p>The boost is multiplied by {@link org.apache.lucene.document.Document#getBoost()} of the document
   34      * containing this field.  If a document has multiple fields with the same
   35      * name, all such values are multiplied together.  This product is then
   36      * multipled by the value {@link org.apache.lucene.search.Similarity#lengthNorm(String,int)}, and
   37      * rounded by {@link org.apache.lucene.search.Similarity#encodeNorm(float)} before it is stored in the
   38      * index.  One should attempt to ensure that this product does not overflow
   39      * the range of that encoding.
   40      *
   41      * @see org.apache.lucene.document.Document#setBoost(float)
   42      * @see org.apache.lucene.search.Similarity#lengthNorm(String, int)
   43      * @see org.apache.lucene.search.Similarity#encodeNorm(float)
   44      */
   45     void setBoost(float boost);
   46   
   47     /** Returns the boost factor for hits for this field.
   48      *
   49      * <p>The default value is 1.0.
   50      *
   51      * <p>Note: this value is not stored directly with the document in the index.
   52      * Documents returned from {@link org.apache.lucene.index.IndexReader#document(int)} and
   53      * {@link org.apache.lucene.search.Hits#doc(int)} may thus not have the same value present as when
   54      * this field was indexed.
   55      *
   56      * @see #setBoost(float)
   57      */
   58     float getBoost();
   59   
   60     /** Returns the name of the field as an interned string.
   61      * For example "date", "title", "body", ...
   62      */
   63     String name();
   64   
   65     /** The value of the field as a String, or null.  If null, the Reader value,
   66      * binary value, or TokenStream value is used.  Exactly one of stringValue(), 
   67      * readerValue(), binaryValue(), and tokenStreamValue() must be set. */
   68     public String stringValue();
   69     
   70     /** The value of the field as a Reader, or null.  If null, the String value,
   71      * binary value, or TokenStream value is used.  Exactly one of stringValue(), 
   72      * readerValue(), binaryValue(), and tokenStreamValue() must be set. */
   73     public Reader readerValue();
   74     
   75     /** The value of the field in Binary, or null.  If null, the Reader value,
   76      * String value, or TokenStream value is used. Exactly one of stringValue(), 
   77      * readerValue(), binaryValue(), and tokenStreamValue() must be set. */
   78     public byte[] binaryValue();
   79     
   80     /** The value of the field as a TokenStream, or null.  If null, the Reader value,
   81      * String value, or binary value is used. Exactly one of stringValue(), 
   82      * readerValue(), binaryValue(), and tokenStreamValue() must be set. */
   83     public TokenStream tokenStreamValue();
   84   
   85     /** True iff the value of the field is to be stored in the index for return
   86       with search hits.  It is an error for this to be true if a field is
   87       Reader-valued. */
   88     boolean  isStored();
   89   
   90     /** True iff the value of the field is to be indexed, so that it may be
   91       searched on. */
   92     boolean  isIndexed();
   93   
   94     /** True iff the value of the field should be tokenized as text prior to
   95       indexing.  Un-tokenized fields are indexed as a single word and may not be
   96       Reader-valued. */
   97     boolean  isTokenized();
   98   
   99     /** True if the value of the field is stored and compressed within the index */
  100     boolean  isCompressed();
  101   
  102     /** True iff the term or terms used to index this field are stored as a term
  103      *  vector, available from {@link org.apache.lucene.index.IndexReader#getTermFreqVector(int,String)}.
  104      *  These methods do not provide access to the original content of the field,
  105      *  only to terms used to index it. If the original content must be
  106      *  preserved, use the <code>stored</code> attribute instead.
  107      *
  108      * @see org.apache.lucene.index.IndexReader#getTermFreqVector(int, String)
  109      */
  110     boolean isTermVectorStored();
  111   
  112     /**
  113      * True iff terms are stored as term vector together with their offsets 
  114      * (start and end positon in source text).
  115      */
  116     boolean isStoreOffsetWithTermVector();
  117   
  118     /**
  119      * True iff terms are stored as term vector together with their token positions.
  120      */
  121     boolean isStorePositionWithTermVector();
  122   
  123     /** True iff the value of the filed is stored as binary */
  124     boolean  isBinary();
  125   
  126     /** True if norms are omitted for this indexed field */
  127     boolean getOmitNorms();
  128   
  129     /** Expert:
  130      *
  131      * If set, omit normalization factors associated with this indexed field.
  132      * This effectively disables indexing boosts and length normalization for this field.
  133      */
  134     void setOmitNorms(boolean omitNorms);
  135   
  136     /**
  137      * Indicates whether a Field is Lazy or not.  The semantics of Lazy loading are such that if a Field is lazily loaded, retrieving
  138      * it's values via {@link #stringValue()} or {@link #binaryValue()} is only valid as long as the {@link org.apache.lucene.index.IndexReader} that
  139      * retrieved the {@link Document} is still open.
  140      *  
  141      * @return true if this field can be loaded lazily
  142      */
  143     boolean isLazy();
  144   }

Save This Page
Home » lucene-2.3.2-src » org.apache » lucene » document » [javadoc | source]