KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > snapper > api > Field


1 package org.enhydra.snapper.api;
2
3 /**
4
5  */

6
7 import java.io.Reader JavaDoc;
8 import java.util.Date JavaDoc;
9
10
11 /**
12   A field is a section of a Document. Each field has two parts, a name and a
13   value. Values may be free text, provided as a String or as a Reader, or they
14   may be atomic keywords, which are not further processed. Such keywords may
15   be used to represent dates, urls, etc. Fields are optionally stored in the
16   index, so that they may be returned with hits on the document.
17   */

18
19 public interface Field {
20
21
22   /** Sets the boost factor hits on this field. This value will be
23    * multiplied into the score of all hits on this this field of this
24    * document.
25    *
26    * <p>The boost is multiplied by {@link Document#getBoost()} of the document
27    * containing this field. If a document has multiple fields with the same
28    * name, all such values are multiplied together. This product is then
29    * multipled by the value {@link Similarity#lengthNorm(String,int)}, and
30    * rounded by {@link Similarity#encodeNorm(float)} before it is stored in the
31    * index. One should attempt to ensure that this product does not overflow
32    * the range of that encoding.
33    *
34    * @see Document#setBoost(float)
35    * @see Similarity#lengthNorm(String, int)
36    * @see Similarity#encodeNorm(float)
37    */

38   public void setBoost(float boost);
39
40   /** Returns the boost factor for hits on any field of this document.
41    *
42    * <p>The default value is 1.0.
43    *
44    * <p>Note: this value is not stored directly with the document in the index.
45    * Documents returned from {@link IndexReader#document(int)} and {@link
46    * Hits#doc(int)} may thus not have the same value present as when this field
47    * was indexed.
48    *
49    * @see #setBoost(float)
50    */

51   public float getBoost() ;
52
53   /** Constructs a String-valued Field that is not tokenized, but is indexed
54     and stored. Useful for non-text fields, e.g. date or url.
55    */

56   public Field Keyword(String JavaDoc name, String JavaDoc value);
57
58   /** Constructs a String-valued Field that is not tokenized nor indexed,
59     but is stored in the index, for return with hits. */

60   public Field UnIndexed(String JavaDoc name, String JavaDoc value);
61
62   /** Constructs a String-valued Field that is tokenized and indexed,
63     and is stored in the index, for return with hits. Useful for short text
64     fields, like "title" or "subject". Term vector will not be stored for this field. */

65   public Field Text(String JavaDoc name, String JavaDoc value);
66
67   /** Constructs a Date-valued Field that is not tokenized and is indexed,
68       and stored in the index, for return with hits. */

69   public Field Keyword(String JavaDoc name, Date JavaDoc value) ;
70
71   /** Constructs a String-valued Field that is tokenized and indexed,
72     and is stored in the index, for return with hits. Useful for short text
73     fields, like "title" or "subject". */

74   public Field Text(String JavaDoc name, String JavaDoc value, boolean storeTermVector);
75
76   /** Constructs a String-valued Field that is tokenized and indexed,
77     but that is not stored in the index. Term vector will not be stored for this field. */

78   public Field UnStored(String JavaDoc name, String JavaDoc value);
79
80   /** Constructs a String-valued Field that is tokenized and indexed,
81     but that is not stored in the index. */

82   public Field UnStored(String JavaDoc name, String JavaDoc value, boolean storeTermVector);
83   /** Constructs a Reader-valued Field that is tokenized and indexed, but is
84     not stored in the index verbatim. Useful for longer text fields, like
85     "body". Term vector will not be stored for this field. */

86   public Field Text(String JavaDoc name, Reader value);
87
88   /** Constructs a Reader-valued Field that is tokenized and indexed, but is
89     not stored in the index verbatim. Useful for longer text fields, like
90     "body". */

91   public Field Text(String JavaDoc name, Reader value, boolean storeTermVector);
92
93   /** The name of the field (e.g., "date", "subject", "title", or "body")
94     as an interned string. */

95   public String JavaDoc name();
96
97   /** The value of the field as a String, or null. If null, the Reader value
98     is used. Exactly one of stringValue() and readerValue() must be set. */

99   public String JavaDoc stringValue();
100   /** The value of the field as a Reader, or null. If null, the String value
101     is used. Exactly one of stringValue() and readerValue() must be set. */

102   public Reader readerValue();
103
104  
105
106   /** True iff the value of the field is to be stored in the index for return
107     with search hits. It is an error for this to be true if a field is
108     Reader-valued. */

109   public boolean isStored() ;
110
111   /** True iff the value of the field is to be indexed, so that it may be
112     searched on. */

113   public boolean isIndexed();
114
115   /** True iff the value of the field should be tokenized as text prior to
116     indexing. Un-tokenized fields are indexed as a single word and may not be
117     Reader-valued. */

118   public boolean isTokenized() ;
119
120   /** True iff the term or terms used to index this field are stored as a term
121    * vector, available from {@link IndexReader#getTermFreqVector(int,String)}.
122    * These methods do not provide access to the original content of the field,
123    * only to terms used to index it. If the original content must be
124    * preserved, use the <code>stored</code> attribute instead.
125    *
126    * @see IndexReader#getTermFreqVector(int, String)
127    */

128   public boolean isTermVectorStored();
129 }
130
131
Popular Tags