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

Loading...
Searching...
No Matches
MultiPhraseQuery.h
Go to the documentation of this file.
1
2// 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 MULTIPHRASEQUERY_H
8#define MULTIPHRASEQUERY_H
9
10#include "Query.h"
11
12 namespace Lucene {
13
18 class LPPAPI MultiPhraseQuery : public Query {
19 public:
20 MultiPhraseQuery();
21 virtual ~MultiPhraseQuery();
22
23 LUCENE_CLASS(MultiPhraseQuery);
24
25 protected:
26 String field;
27 Collection< Collection<TermPtr> > termArrays;
28 Collection<int32_t> positions;
29 int32_t slop;
30
31 public:
32 using Query::toString;
33
36 void setSlop(int32_t s);
37
40 int32_t getSlop();
41
44 void add(const TermPtr& term);
45
48 void add(Collection<TermPtr> terms);
49
52 void add(Collection<TermPtr> terms, int32_t position);
53
55 Collection< Collection<TermPtr> > getTermArrays();
56
58 Collection<int32_t> getPositions();
59
60 virtual void extractTerms(SetTerm terms);
61 virtual QueryPtr rewrite(const IndexReaderPtr& reader);
62 virtual WeightPtr createWeight(const SearcherPtr& searcher);
63
65 virtual String toString(const String& field);
66
67 virtual bool equals(const LuceneObjectPtr& other);
68 virtual int32_t hashCode();
69 virtual LuceneObjectPtr clone(const LuceneObjectPtr& other = LuceneObjectPtr());
70
71 protected:
72 int32_t termArraysHashCode();
73 bool termArraysEquals(Collection< Collection<TermPtr> > first, Collection< Collection<TermPtr> > second);
74
75 friend class MultiPhraseWeight;
76};
77
78}
79
80#endif
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition LuceneObject.h:24
Query.h
Lucene::Collection
Utility template class to handle collections that can be safely copied and shared.
Definition Collection.h:17
Lucene::MultiPhraseQuery::equals
virtual bool equals(const LuceneObjectPtr &other)
Return whether two objects are equal.
Lucene::MultiPhraseQuery::MultiPhraseWeight
friend class MultiPhraseWeight
Definition MultiPhraseQuery.h:75
Lucene::MultiPhraseQuery::getSlop
int32_t getSlop()
Gets the phrase slop for this query.
Lucene::MultiPhraseQuery::setSlop
void setSlop(int32_t s)
Sets the phrase slop for this query.
Lucene::MultiPhraseQuery::clone
virtual LuceneObjectPtr clone(const LuceneObjectPtr &other=LuceneObjectPtr())
Returns a clone of this query.
Lucene::MultiPhraseQuery::hashCode
virtual int32_t hashCode()
Return hash code for this object.
Lucene::MultiPhraseQuery::toString
virtual String toString(const String &field)
Prints a user-readable version of this query.
Lucene::MultiPhraseQuery::rewrite
virtual QueryPtr rewrite(const IndexReaderPtr &reader)
Called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into ...
Lucene::MultiPhraseQuery::createWeight
virtual WeightPtr createWeight(const SearcherPtr &searcher)
Constructs an appropriate Weight implementation for this query. Only implemented by primitive queries...
Lucene::MultiPhraseQuery::slop
int32_t slop
Definition MultiPhraseQuery.h:29
Lucene::MultiPhraseQuery::add
void add(Collection< TermPtr > terms)
Add multiple terms at the next position in the phrase. Any of the terms may match.
Lucene::MultiPhraseQuery::add
void add(const TermPtr &term)
Add a single term at the next position in the phrase.
Lucene::MultiPhraseQuery::MultiPhraseQuery
MultiPhraseQuery()
Lucene::MultiPhraseQuery::positions
Collection< int32_t > positions
Definition MultiPhraseQuery.h:28
Lucene::MultiPhraseQuery::~MultiPhraseQuery
virtual ~MultiPhraseQuery()
Lucene::MultiPhraseQuery::field
String field
Definition MultiPhraseQuery.h:26
Lucene::MultiPhraseQuery::termArraysEquals
bool termArraysEquals(Collection< Collection< TermPtr > > first, Collection< Collection< TermPtr > > second)
Lucene::MultiPhraseQuery::getTermArrays
Collection< Collection< TermPtr > > getTermArrays()
Returns a List of the terms in the multiphrase. Do not modify the List or its contents.
Lucene::MultiPhraseQuery::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::MultiPhraseQuery::termArrays
Collection< Collection< TermPtr > > termArrays
Definition MultiPhraseQuery.h:27
Lucene::MultiPhraseQuery::getPositions
Collection< int32_t > getPositions()
Returns the relative positions of terms in this phrase.
Lucene::MultiPhraseQuery::add
void add(Collection< TermPtr > terms, int32_t position)
Allows to specify the relative position of terms within the phrase.
Lucene::MultiPhraseQuery::termArraysHashCode
int32_t termArraysHashCode()
Lucene::Query::Query
Query()
Lucene::Query::toString
virtual String toString(const String &field)
Prints a query to a string, with field assumed to be the default field and omitted.
Lucene
Definition AbstractAllTermDocs.h:12
Lucene::QueryPtr
boost::shared_ptr< Query > QueryPtr
Definition LuceneTypes.h:420
Lucene::WeightPtr
boost::shared_ptr< Weight > WeightPtr
Definition LuceneTypes.h:480
Lucene::SearcherPtr
boost::shared_ptr< Searcher > SearcherPtr
Definition LuceneTypes.h:434
Lucene::LuceneObjectPtr
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition LuceneTypes.h:539
Lucene::TermPtr
boost::shared_ptr< Term > TermPtr
Definition LuceneTypes.h:233
Lucene::IndexReaderPtr
boost::shared_ptr< IndexReader > IndexReaderPtr
Definition LuceneTypes.h:157

clucene.sourceforge.net