Lucene++ - a full-featured, c++ search engine
API Documentation


Field.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2014 Alan Wright. All rights reserved.
3 // Distributable under the terms of either the Apache License (Version 2.0)
4 // or the GNU Lesser General Public License.
6 
7 #ifndef FIELD_H
8 #define FIELD_H
9 
10 #include "AbstractField.h"
11 
12 namespace Lucene {
13 
14 class LPPAPI Field : public AbstractField {
15 public:
23  Field(const String& name, const String& value, Store store, Index index);
24 
32  Field(const String& name, const String& value, Store store, Index index, TermVector termVector);
33 
40  Field(const String& name, const ReaderPtr& reader);
41 
49  Field(const String& name, const ReaderPtr& reader, TermVector termVector);
50 
57  Field(const String& name, const TokenStreamPtr& tokenStream);
58 
66  Field(const String& name, const TokenStreamPtr& tokenStream, TermVector termVector);
67 
73  Field(const String& name, ByteArray value, Store store);
74 
82  Field(const String& name, ByteArray value, int32_t offset, int32_t length, Store store);
83 
84  virtual ~Field();
85 
87 
88 public:
91 
93  static bool isStored(Store store);
94 
96  static bool isIndexed(Index index);
97  static bool isAnalyzed(Index index);
98  static bool omitNorms(Index index);
99 
101  static Field::Index toIndex(bool indexed, bool analyzed);
102 
104  static Field::Index toIndex(bool indexed, bool analyzed, bool omitNorms);
105 
107  static bool isStored(TermVector termVector);
108  static bool withPositions(TermVector termVector);
109  static bool withOffsets(TermVector termVector);
110 
112  static Field::TermVector toTermVector(bool stored, bool withOffsets, bool withPositions);
113 
116  virtual String stringValue();
117 
121 
125 
131  virtual void setValue(const String& value);
132 
134  virtual void setValue(const ReaderPtr& value);
135 
137  virtual void setValue(ByteArray value);
138 
140  virtual void setValue(ByteArray value, int32_t offset, int32_t length);
141 
144  virtual void setTokenStream(const TokenStreamPtr& tokenStream);
145 
146 protected:
147  void ConstructField(const String& name, const String& value, Store store, Index index, TermVector termVector);
148  void ConstructField(const String& name, const ReaderPtr& reader, TermVector termVector);
149  void ConstructField(const String& name, const TokenStreamPtr& tokenStream, TermVector termVector);
150  void ConstructField(const String& name, ByteArray value, int32_t offset, int32_t length, Store store);
151 };
152 
153 }
154 
155 #endif
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
Definition: AbstractField.h:14
virtual bool isStored()
True if the value of the field is to be stored in the index for return with search hits....
virtual bool isIndexed()
True if the value of the field is to be indexed, so that it may be searched on.
Store
Specifies whether and how a field should be stored.
Definition: AbstractField.h:17
Index
Specifies whether and how a field should be indexed.
Definition: AbstractField.h:28
TermVector
Specifies whether and how a field should have term vectors.
Definition: AbstractField.h:57
Definition: Field.h:14
virtual ~Field()
Field(const String &name, const ReaderPtr &reader)
Create a tokenized and indexed field that is not stored. Term vectors will not be stored....
static bool isIndexed(Index index)
Specifies whether and how a field should be indexed.
void ConstructField(const String &name, ByteArray value, int32_t offset, int32_t length, Store store)
static bool isStored(TermVector termVector)
Specifies whether and how a field should have term vectors.
virtual ReaderPtr readerValue()
The value of the field as a Reader, or null. If null, the String value or binary value is used....
static bool withOffsets(TermVector termVector)
virtual void setValue(ByteArray value)
Change the value of this field.
Field(const String &name, ByteArray value, int32_t offset, int32_t length, Store store)
Create a stored field with binary value. Optionally the value may be compressed.
Field(const String &name, const TokenStreamPtr &tokenStream)
Create a tokenized and indexed field that is not stored. Term vectors will not be stored....
virtual String stringValue()
The value of the field as a String, or null. If null, the Reader value or binary value is used....
Field(const String &name, const ReaderPtr &reader, TermVector termVector)
Create a tokenized and indexed field that is not stored, optionally with storing term vectors....
Field(const String &name, const String &value, Store store, Index index, TermVector termVector)
Create a field by specifying its name, value and how it will be saved in the index.
void ConstructField(const String &name, const String &value, Store store, Index index, TermVector termVector)
static bool isStored(Store store)
Specifies whether and how a field should be stored.
virtual TokenStreamPtr tokenStreamValue()
The value of the field as a TokesStream, or null. If null, the Reader value or String value is analyz...
virtual void setValue(const String &value)
Change the value of this field. This can be used during indexing to re-use a single Field instance to...
static bool withPositions(TermVector termVector)
virtual void setTokenStream(const TokenStreamPtr &tokenStream)
Sets the token stream to be used for indexing and causes isIndexed() and isTokenized() to return true...
static Field::Index toIndex(bool indexed, bool analyzed, bool omitNorms)
Get the best representation of the index given the flags.
static Field::TermVector toTermVector(bool stored, bool withOffsets, bool withPositions)
Get the best representation of the index given the flags.
void ConstructField(const String &name, const TokenStreamPtr &tokenStream, TermVector termVector)
static Field::Index toIndex(bool indexed, bool analyzed)
Get the best representation of the index given the flags.
static bool isAnalyzed(Index index)
void ConstructField(const String &name, const ReaderPtr &reader, TermVector termVector)
Field(const String &name, ByteArray value, Store store)
Create a stored field with binary value. Optionally the value may be compressed.
Field(const String &name, const String &value, Store store, Index index)
Create a field by specifying its name, value and how it will be saved in the index....
Field(const String &name, const TokenStreamPtr &tokenStream, TermVector termVector)
Create a tokenized and indexed field that is not stored, optionally with storing term vectors....
virtual void setValue(ByteArray value, int32_t offset, int32_t length)
Change the value of this field.
static bool omitNorms(Index index)
virtual void setValue(const ReaderPtr &value)
Change the value of this field.
Definition: AbstractAllTermDocs.h:12
boost::shared_ptr< TokenStream > TokenStreamPtr
Definition: LuceneTypes.h:63
boost::shared_ptr< Reader > ReaderPtr
Definition: LuceneTypes.h:547

clucene.sourceforge.net