1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * mgqueryfilter.h -- queryfilter for old mg
|
---|
4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
5 | *
|
---|
6 | * A component of the Greenstone digital library software
|
---|
7 | * from the New Zealand Digital Library Project at the
|
---|
8 | * University of Waikato, New Zealand.
|
---|
9 | *
|
---|
10 | * This program is free software; you can redistribute it and/or modify
|
---|
11 | * it under the terms of the GNU General Public License as published by
|
---|
12 | * the Free Software Foundation; either version 2 of the License, or
|
---|
13 | * (at your option) any later version.
|
---|
14 | *
|
---|
15 | * This program is distributed in the hope that it will be useful,
|
---|
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
18 | * GNU General Public License for more details.
|
---|
19 | *
|
---|
20 | * You should have received a copy of the GNU General Public License
|
---|
21 | * along with this program; if not, write to the Free Software
|
---|
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
23 | *
|
---|
24 | * $Id: mgqueryfilter.h 4193 2003-04-18 02:25:00Z sjboddie $
|
---|
25 | *
|
---|
26 | *********************************************************************/
|
---|
27 |
|
---|
28 |
|
---|
29 | #ifndef MGQUERYFILTER_H
|
---|
30 | #define MGQUERYFILTER_H
|
---|
31 |
|
---|
32 | #include "queryfilter.h"
|
---|
33 |
|
---|
34 | // resultsorderer_t is used to sort the query results
|
---|
35 | struct resultsorderer_t {
|
---|
36 | bool compare_phrase_match;
|
---|
37 | bool compare_terms_match;
|
---|
38 | bool compare_doc_weight;
|
---|
39 | docresultmap *docset;
|
---|
40 |
|
---|
41 | resultsorderer_t();
|
---|
42 | void clear();
|
---|
43 | bool operator()(const int &t1, const int &t2) const;
|
---|
44 | };
|
---|
45 |
|
---|
46 |
|
---|
47 |
|
---|
48 | class mgqueryfilterclass : public queryfilterclass {
|
---|
49 | protected:
|
---|
50 |
|
---|
51 | int num_phrases;
|
---|
52 |
|
---|
53 | int maxnumeric;
|
---|
54 |
|
---|
55 | void get_phrase_terms (const text_t &querystring,
|
---|
56 | const termfreqclassarray &orgterms,
|
---|
57 | vector<termfreqclassarray> &phrases);
|
---|
58 |
|
---|
59 | // do aditional query processing
|
---|
60 | virtual void post_process (const queryparamclass &queryparams,
|
---|
61 | queryresultsclass &queryresults);
|
---|
62 |
|
---|
63 | // do query that might involve multiple sub queries
|
---|
64 | // mgsearchptr and gdbmptr are assumed to be valid
|
---|
65 | void do_multi_query (const FilterRequest_t &request,
|
---|
66 | const vector<queryparamclass> &query_params,
|
---|
67 | queryresultsclass &multiresults,
|
---|
68 | comerror_t &err, ostream &logout);
|
---|
69 |
|
---|
70 | virtual void sort_doc_results (const FilterRequest_t &request,
|
---|
71 | docresultsclass &docs);
|
---|
72 |
|
---|
73 | virtual void mg_parse_query_params (const FilterRequest_t &request,
|
---|
74 | vector<queryparamclass> &query_params,
|
---|
75 | int &startresults, int &endresults,
|
---|
76 | text_t &phrasematch, ostream &logout);
|
---|
77 |
|
---|
78 |
|
---|
79 | public:
|
---|
80 | mgqueryfilterclass ();
|
---|
81 | virtual ~mgqueryfilterclass ();
|
---|
82 |
|
---|
83 | virtual void configure (const text_t &key, const text_tarray &cfgline);
|
---|
84 |
|
---|
85 | void filter (const FilterRequest_t &request,
|
---|
86 | FilterResponse_t &response,
|
---|
87 | comerror_t &err, ostream &logout);
|
---|
88 | };
|
---|
89 |
|
---|
90 |
|
---|
91 | #endif
|
---|
92 |
|
---|