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


PhraseQuery.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 PHRASEQUERY_H
8 #define PHRASEQUERY_H
9 
10 #include "Query.h"
11 
12 namespace Lucene {
13 
18 class LPPAPI PhraseQuery : public Query {
19 public:
22  virtual ~PhraseQuery();
23 
25 
26 protected:
27  String field;
30  int32_t maxPosition;
31  int32_t slop;
32 
33 public:
34  using Query::toString;
35 
46  void setSlop(int32_t slop);
47 
50  int32_t getSlop();
51 
54  void add(const TermPtr& term);
55 
59  void add(const TermPtr& term, int32_t position);
60 
63 
66 
67  virtual WeightPtr createWeight(const SearcherPtr& searcher);
68  virtual void extractTerms(SetTerm terms);
69 
71  virtual String toString(const String& field);
72 
73  virtual bool equals(const LuceneObjectPtr& other);
74  virtual int32_t hashCode();
76 
77  friend class PhraseWeight;
78 };
79 
80 }
81 
82 #endif
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
Lucene::TermPtr
boost::shared_ptr< Term > TermPtr
Definition: LuceneTypes.h:233
Lucene::PhraseQuery::setSlop
void setSlop(int32_t slop)
Sets the number of other words permitted between words in query phrase. If zero, then this is an exac...
Lucene::Collection< TermPtr >
Lucene::LuceneObjectPtr
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition: LuceneTypes.h:539
Lucene::PhraseQuery
A Query that matches documents containing a particular sequence of terms. A PhraseQuery is built by Q...
Definition: PhraseQuery.h:18
Lucene::PhraseQuery::field
String field
Definition: PhraseQuery.h:24
Lucene::PhraseQuery::add
void add(const TermPtr &term, int32_t position)
Adds a term to the end of the query phrase. The relative position of the term within the phrase is sp...
Lucene::PhraseQuery::maxPosition
int32_t maxPosition
Definition: PhraseQuery.h:30
Query.h
Lucene::PhraseQuery::toString
virtual String toString(const String &field)
Prints a user-readable version of this query.
Lucene
Definition: AbstractAllTermDocs.h:12
Lucene::PhraseQuery::equals
virtual bool equals(const LuceneObjectPtr &other)
Return whether two objects are equal.
Lucene::PhraseQuery::PhraseQuery
PhraseQuery()
Constructs an empty phrase query.
Lucene::PhraseQuery::getSlop
int32_t getSlop()
Returns the slop.
Lucene::WeightPtr
boost::shared_ptr< Weight > WeightPtr
Definition: LuceneTypes.h:480
Lucene::PhraseQuery::getPositions
Collection< int32_t > getPositions()
Returns the relative positions of terms in this phrase.
Lucene::PhraseQuery::getTerms
Collection< TermPtr > getTerms()
Returns the set of terms in this phrase.
Lucene::Query
The abstract base class for queries.
Definition: Query.h:31
Lucene::PhraseQuery::terms
Collection< TermPtr > terms
Definition: PhraseQuery.h:28
Lucene::PhraseQuery::hashCode
virtual int32_t hashCode()
Return hash code for this object.
Lucene::PhraseQuery::~PhraseQuery
virtual ~PhraseQuery()
Lucene::PhraseQuery::slop
int32_t slop
Definition: PhraseQuery.h:31
Lucene::PhraseQuery::positions
Collection< int32_t > positions
Definition: PhraseQuery.h:29
Lucene::PhraseQuery::createWeight
virtual WeightPtr createWeight(const SearcherPtr &searcher)
Constructs an appropriate Weight implementation for this query. Only implemented by primitive queries...
Lucene::PhraseQuery::extractTerms
virtual void extractTerms(SetTerm terms)
Adds all terms occurring in this query to the terms set. Only works if this query is in its rewritten...
Lucene::PhraseQuery::add
void add(const TermPtr &term)
Adds a term to the end of the query phrase. The relative position of the term is the one immediately ...
Lucene::Query::toString
virtual String toString()
Prints a query to a string.
Lucene::PhraseQuery::clone
virtual LuceneObjectPtr clone(const LuceneObjectPtr &other=LuceneObjectPtr())
Returns a clone of this query.
Lucene::SearcherPtr
boost::shared_ptr< Searcher > SearcherPtr
Definition: LuceneTypes.h:434

clucene.sourceforge.net