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


Scorer.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 SCORER_H
8 #define SCORER_H
9 
10 #include "DocIdSetIterator.h"
11 #include "BooleanClause.h"
12 #include "Weight.h"
13 
14 namespace Lucene {
15 
16 
17  class LPPAPI ScorerVisitor{
18  public:
19  virtual void visitOptional(QueryPtr parent,QueryPtr child,ScorerPtr scorer)=0;
20  virtual void visitRequired(QueryPtr parent,QueryPtr child,ScorerPtr scorer)=0;
21  virtual void visitProhibited(QueryPtr parent,QueryPtr child,ScorerPtr scorer)=0;
22 
23  };
24 
33 class LPPAPI Scorer : public DocIdSetIterator {
34 public:
37  Scorer(const SimilarityPtr& similarity);
38  Scorer(const WeightPtr& weight);
39  virtual ~Scorer();
40 
43 
44 protected:
46 
47 public:
50 
53  virtual void score(const CollectorPtr& collector);
54 
58  virtual double score() = 0;
59 
60  void visitSubScorers(QueryPtr parent, BooleanClause::Occur relationship,
61  ScorerVisitor *visitor);
62 
63  void visitScorers(ScorerVisitor *visitor);
64 
65  virtual float termFreq(){
66  boost::throw_exception(RuntimeException(L"Freq not implemented"));
67  }
68 
69 protected:
77  virtual bool score(const CollectorPtr& collector, int32_t max, int32_t firstDocID);
78 
79  friend class BooleanScorer;
81 };
82 
83 
84 }
85 
86 #endif
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
Occur
Specifies how clauses are to occur in matching documents.
Definition: BooleanClause.h:18
BooleanScorer uses a ~16k array to score windows of docs. So it scores docs 0-16k first,...
Definition: BooleanScorer.h:30
This abstract class defines methods to iterate over a set of non-decreasing doc ids....
Definition: DocIdSetIterator.h:17
A Scorer which wraps another scorer and caches the score of the current document. Successive calls to...
Definition: ScoreCachingWrappingScorer.h:22
Definition: Scorer.h:17
virtual void visitProhibited(QueryPtr parent, QueryPtr child, ScorerPtr scorer)=0
virtual void visitOptional(QueryPtr parent, QueryPtr child, ScorerPtr scorer)=0
virtual void visitRequired(QueryPtr parent, QueryPtr child, ScorerPtr scorer)=0
Common scoring functionality for different types of queries.
Definition: Scorer.h:33
virtual void score(const CollectorPtr &collector)
Scores and collects all matching documents.
void visitSubScorers(QueryPtr parent, BooleanClause::Occur relationship, ScorerVisitor *visitor)
Scorer(const WeightPtr &weight)
virtual ~Scorer()
SimilarityPtr similarity
Definition: Scorer.h:45
virtual double score()=0
Returns the score of the current document matching the query. Initially invalid, until {} or #advanc...
void visitScorers(ScorerVisitor *visitor)
virtual bool score(const CollectorPtr &collector, int32_t max, int32_t firstDocID)
Collects matching documents in a range. Hook for optimization. Note, firstDocID is added to ensure th...
Scorer(const SimilarityPtr &similarity)
Constructs a Scorer.
WeightPtr weight
Definition: Scorer.h:41
virtual float termFreq()
Definition: Scorer.h:65
SimilarityPtr getSimilarity()
Returns the Similarity implementation used by this scorer.
Definition: AbstractAllTermDocs.h:12
boost::shared_ptr< Query > QueryPtr
Definition: LuceneTypes.h:420
boost::shared_ptr< Similarity > SimilarityPtr
Definition: LuceneTypes.h:435
boost::shared_ptr< Collector > CollectorPtr
Definition: LuceneTypes.h:295
ExceptionTemplate< LuceneException, LuceneException::Runtime > RuntimeException
Definition: LuceneException.h:73
boost::shared_ptr< Scorer > ScorerPtr
Definition: LuceneTypes.h:429
boost::shared_ptr< Weight > WeightPtr
Definition: LuceneTypes.h:480

clucene.sourceforge.net