~ubuntu-branches/ubuntu/raring/clucene-core/raring-proposed

« back to all changes in this revision

Viewing changes to src/core/CLucene/search/SearchHeader.h

  • Committer: Package Import Robot
  • Author(s): Fathi Boudra
  • Date: 2012-08-11 09:33:38 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20120811093338-fgrx41ftqew3qt6a
Tags: 2.3.3.4-1
* New upstream release (Closes: #661703).
* Convert package to multiarch.
* Drop obsolete patches:
  - 01_add_missing_include_bug505667.diff
  - 02_posixness_fix_bug530308.diff
* Add patches:
  - Fixing_ZLIB_configuration_in_shared_CMakeLists.patch
  - Fix-pkgconfig-file-by-adding-clucene-shared-library.patch
  - Install-contribs-lib.patch
  - multiarch.patch
* Update debian/compat: bump to 8.
* Update debian/control:
  - update build dependencies (add cmake, libboost-dev and libz-dev).
  - bump Standards-Version to 3.9.3.
  - rename packages due to ABI bump: libclucene0ldbl -> libclucene-core1.
  - add libclucene-contribs1 package.
* Update debian/rules:
  - rewrite to use CMake.
  - add multiarch support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*------------------------------------------------------------------------------
 
2
* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
 
3
 
4
* Distributable under the terms of either the Apache License (Version 2.0) or 
 
5
* the GNU Lesser General Public License, as specified in the COPYING file.
 
6
------------------------------------------------------------------------------*/
 
7
#ifndef _lucene_search_SearchHeader_
 
8
#define _lucene_search_SearchHeader_
 
9
 
 
10
 
 
11
//#include "CLucene/index/IndexReader.h"
 
12
CL_CLASS_DEF(index,Term)
 
13
CL_CLASS_DEF(index,IndexReader)
 
14
//#include "Filter.h"
 
15
CL_CLASS_DEF(document,Document)
 
16
CL_CLASS_DEF(util,Comparable)
 
17
//#include "Sort.h"
 
18
//#include "CLucene/util/VoidList.h"
 
19
//#include "Explanation.h"
 
20
//#include "Similarity.h"
 
21
 
 
22
CL_NS_DEF(search)
 
23
 
 
24
        class Query;
 
25
        class Scorer;
 
26
        class Explanation;
 
27
        class Hits;
 
28
        class Sort;
 
29
        class FieldDoc;
 
30
        class TopFieldDocs;
 
31
   
 
32
   /** Expert: Returned by low-level search implementations.
 
33
        * @see TopDocs */
 
34
        struct CLUCENE_EXPORT ScoreDoc {
 
35
                /** Expert: A hit document's number.
 
36
                * @see Searcher#doc(int32_t)
 
37
                */
 
38
                int32_t doc;
 
39
 
 
40
                /** Expert: The score of this document for the query. */
 
41
                float_t score;
 
42
        };
 
43
 
 
44
        /** Expert: Returned by low-level search implementations.
 
45
        * @see Searcher#search(Query,Filter,int32_t) */
 
46
        class CLUCENE_EXPORT TopDocs:LUCENE_BASE {
 
47
        public:
 
48
                /** Expert: The total number of hits for the query.
 
49
                 * @see Hits#length()
 
50
                */
 
51
                int32_t totalHits;
 
52
 
 
53
                /** Expert: The top hits for the query. */
 
54
                ScoreDoc* scoreDocs;
 
55
                int32_t scoreDocsLength;
 
56
 
 
57
                /** Expert: Constructs a TopDocs. TopDocs takes ownership of the ScoreDoc array*/
 
58
                TopDocs(const int32_t th, ScoreDoc* sds, int32_t scoreDocsLength);
 
59
                virtual ~TopDocs();
 
60
 
 
61
        private:
 
62
                /** Expert: Stores the maximum score value encountered, needed for normalizing. */
 
63
                //float_t maxScore;
 
64
        };
 
65
 
 
66
    /** Lower-level search API.
 
67
    * <br>HitCollectors are primarily meant to be used to implement queries,
 
68
    * sorting and filtering.
 
69
    * @see Searcher#search(Query,HitCollector)
 
70
    */
 
71
        class CLUCENE_EXPORT HitCollector: LUCENE_BASE {
 
72
    public:
 
73
      /** Called once for every non-zero scoring document, with the document number
 
74
      * and its score.
 
75
      *
 
76
      * <P>If, for example, an application wished to collect all of the hits for a
 
77
      * query in a BitSet, then it might:<pre>
 
78
      *   Searcher searcher = new IndexSearcher(indexReader);
 
79
      *   final BitSet bits = new BitSet(indexReader.maxDoc());
 
80
      *   searcher.search(query, new HitCollector() {
 
81
      *       public void collect(int32_t doc, float score) {
 
82
      *         bits.set(doc);
 
83
      *       }
 
84
      *     });
 
85
      * </pre>
 
86
      *
 
87
      * <p>Note: This is called in an inner search loop.  For good search
 
88
      * performance, implementations of this method should not call
 
89
      * {@link Searcher#doc(int32_t)} or
 
90
      * {@link IndexReader#document(int32_t)} on every
 
91
      * document number encountered.  Doing so can slow searches by an order
 
92
      * of magnitude or more.
 
93
      * <p>Note: The <code>score</code> passed to this method is a raw score.
 
94
      * In other words, the score will not necessarily be a float whose value is
 
95
      * between 0 and 1.
 
96
      */
 
97
      virtual void collect(const int32_t doc, const float_t score) = 0;
 
98
      virtual ~HitCollector(){}
 
99
    };
 
100
 
 
101
   /** Expert: Calculate query weights and build query scorers.
 
102
   *
 
103
   * <p>A Weight is constructed by a query, given a Searcher ({@link
 
104
   * Query#_createWeight(Searcher)}).  The {@link #sumOfSquaredWeights()} method
 
105
   * is then called on the top-level query to compute the query normalization
 
106
   * factor (@link Similarity#queryNorm(float_t)}).  This factor is then passed to
 
107
   * {@link #normalize(float_t)}.  At this point the weighting is complete and a
 
108
   * scorer may be constructed by calling {@link #scorer(IndexReader)}.
 
109
   */
 
110
        class CLUCENE_EXPORT Weight
 
111
    {
 
112
    public:
 
113
                virtual ~Weight();
 
114
 
 
115
      /** The query that this concerns. */
 
116
      virtual Query* getQuery() = 0;
 
117
 
 
118
      /** The weight for this query. */
 
119
      virtual float_t getValue() = 0;
 
120
 
 
121
      /** The sum of squared weights of contained query clauses. */
 
122
      virtual float_t sumOfSquaredWeights() = 0;
 
123
 
 
124
      /** Assigns the query normalization factor to this. */
 
125
      virtual void normalize(float_t norm) = 0;
 
126
 
 
127
      /** Constructs a scorer for this. */
 
128
      virtual Scorer* scorer(CL_NS(index)::IndexReader* reader) = 0;
 
129
 
 
130
      /** An explanation of the score computation for the named document. */
 
131
      virtual Explanation* explain(CL_NS(index)::IndexReader* reader, int32_t doc) = 0;
 
132
 
 
133
      virtual TCHAR* toString();
 
134
   };
 
135
 
 
136
   class CLUCENE_EXPORT HitDoc
 
137
   {
 
138
    public:
 
139
                float_t score;
 
140
                int32_t id;
 
141
                CL_NS(document)::Document* doc;
 
142
                
 
143
                HitDoc* next;                                     // in doubly-linked cache
 
144
                HitDoc* prev;                                     // in doubly-linked cache
 
145
                
 
146
                HitDoc(const float_t s, const int32_t i);
 
147
                virtual ~HitDoc();
 
148
    };
 
149
 
 
150
 
 
151
CL_NS_END
 
152
#endif