001: package org.apache.lucene.document;
002:
003: /**
004: * Copyright 2004 The Apache Software Foundation
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: import java.io.Reader;
020: import java.io.Serializable;
021:
022: import org.apache.lucene.analysis.TokenStream;
023:
024: /**
025: * Synonymous with {@link Field}.
026: *
027: **/
028: public interface Fieldable extends Serializable {
029: /** Sets the boost factor hits on this field. This value will be
030: * multiplied into the score of all hits on this this field of this
031: * document.
032: *
033: * <p>The boost is multiplied by {@link org.apache.lucene.document.Document#getBoost()} of the document
034: * containing this field. If a document has multiple fields with the same
035: * name, all such values are multiplied together. This product is then
036: * multipled by the value {@link org.apache.lucene.search.Similarity#lengthNorm(String,int)}, and
037: * rounded by {@link org.apache.lucene.search.Similarity#encodeNorm(float)} before it is stored in the
038: * index. One should attempt to ensure that this product does not overflow
039: * the range of that encoding.
040: *
041: * @see org.apache.lucene.document.Document#setBoost(float)
042: * @see org.apache.lucene.search.Similarity#lengthNorm(String, int)
043: * @see org.apache.lucene.search.Similarity#encodeNorm(float)
044: */
045: void setBoost(float boost);
046:
047: /** Returns the boost factor for hits for this field.
048: *
049: * <p>The default value is 1.0.
050: *
051: * <p>Note: this value is not stored directly with the document in the index.
052: * Documents returned from {@link org.apache.lucene.index.IndexReader#document(int)} and
053: * {@link org.apache.lucene.search.Hits#doc(int)} may thus not have the same value present as when
054: * this field was indexed.
055: *
056: * @see #setBoost(float)
057: */
058: float getBoost();
059:
060: /** Returns the name of the field as an interned string.
061: * For example "date", "title", "body", ...
062: */
063: String name();
064:
065: /** The value of the field as a String, or null. If null, the Reader value,
066: * binary value, or TokenStream value is used. Exactly one of stringValue(),
067: * readerValue(), binaryValue(), and tokenStreamValue() must be set. */
068: public String stringValue();
069:
070: /** The value of the field as a Reader, or null. If null, the String value,
071: * binary value, or TokenStream value is used. Exactly one of stringValue(),
072: * readerValue(), binaryValue(), and tokenStreamValue() must be set. */
073: public Reader readerValue();
074:
075: /** The value of the field in Binary, or null. If null, the Reader value,
076: * String value, or TokenStream value is used. Exactly one of stringValue(),
077: * readerValue(), binaryValue(), and tokenStreamValue() must be set. */
078: public byte[] binaryValue();
079:
080: /** The value of the field as a TokenStream, or null. If null, the Reader value,
081: * String value, or binary value is used. Exactly one of stringValue(),
082: * readerValue(), binaryValue(), and tokenStreamValue() must be set. */
083: public TokenStream tokenStreamValue();
084:
085: /** True iff the value of the field is to be stored in the index for return
086: with search hits. It is an error for this to be true if a field is
087: Reader-valued. */
088: boolean isStored();
089:
090: /** True iff the value of the field is to be indexed, so that it may be
091: searched on. */
092: boolean isIndexed();
093:
094: /** True iff the value of the field should be tokenized as text prior to
095: indexing. Un-tokenized fields are indexed as a single word and may not be
096: Reader-valued. */
097: boolean isTokenized();
098:
099: /** 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: }
|