summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/clucene/src/CLucene/search/MultiSearcher.h
blob: 1021fbbec48961b0e588e1300d58162733d061ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*------------------------------------------------------------------------------
* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
* 
* Distributable under the terms of either the Apache License (Version 2.0) or 
* the GNU Lesser General Public License, as specified in the COPYING file.
------------------------------------------------------------------------------*/
#ifndef _lucene_search_multisearcher
#define _lucene_search_multisearcher

#if defined(_LUCENE_PRAGMA_ONCE)
# pragma once
#endif

#include "SearchHeader.h"
#include "CLucene/document/Document.h"
#include "CLucene/index/Term.h"

CL_NS_DEF(search)
    
    class MultiHitCollector: public HitCollector{
    private:
      HitCollector* results;
      int32_t start;
    public: 
      MultiHitCollector(HitCollector* _results, int32_t _start);
      void collect(const int32_t doc, const qreal score) ;
    };
    
    
 /** Implements search over a set of <code>Searchables</code>.
	*
	* <p>Applications usually need only call the inherited {@link #search(Query)}
	* or {@link #search(Query,Filter)} methods.
	*/
	class MultiSearcher: public Searcher {
  private:
    Searchable** searchables;
		int32_t searchablesLen;
    int32_t* starts;
    int32_t _maxDoc;
	protected:
		int32_t* getStarts() {
  			return starts;
		}

  public:
      /** Creates a searcher which searches <i>Searchables</i>. */
      MultiSearcher(Searchable** searchables);
      
      ~MultiSearcher();

      /** Frees resources associated with this <code>Searcher</code>. */
      void close() ;

	  int32_t docFreq(const CL_NS(index)::Term* term) const ;

      /** For use by {@link HitCollector} implementations. */
	  bool doc(int32_t n, CL_NS(document)::Document* document);

      /** For use by {@link HitCollector} implementations to identify the
       * index of the sub-searcher that a particular hit came from. */
      int32_t searcherIndex(int32_t n) const;

	  int32_t subSearcher(int32_t n) const;

	  int32_t subDoc(int32_t n) const;

      int32_t maxDoc() const;
    
      TopDocs* _search(Query* query, Filter* filter, const int32_t nDocs) ;
      
      TopFieldDocs* _search (Query* query, Filter* filter, const int32_t n, const Sort* sort);
     
      /** Lower-level search API.
       *
       * <p>{@link HitCollector#collect(int32_t,qreal)} is called for every non-zero
       * scoring document.
       *
       * <p>Applications should only use this if they need <i>all</i> of the
       * matching documents.  The high-level search API ({@link
       * Searcher#search(Query)}) is usually more efficient, as it skips
       * non-high-scoring hits.
       *
       * @param query to match documents
       * @param filter if non-null, a bitset used to eliminate some documents
       * @param results to receive hits
       */
        void _search(Query* query, Filter* filter, HitCollector* results);

		Query* rewrite(Query* original);
		void explain(Query* query, int32_t doc, Explanation* ret);
    };

CL_NS_END
#endif