1 | /**********************************************************************
|
---|
2 | *
|
---|
3 | * queryfilter.h --
|
---|
4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
5 | *
|
---|
6 | * PUT COPYRIGHT NOTICE HERE
|
---|
7 | *
|
---|
8 | * $Id: queryfilter.h 351 1999-07-07 06:19:47Z rjmcnab $
|
---|
9 | *
|
---|
10 | *********************************************************************/
|
---|
11 |
|
---|
12 |
|
---|
13 | #ifndef QUERYFILTER_H
|
---|
14 | #define QUERYFILTER_H
|
---|
15 |
|
---|
16 |
|
---|
17 | #include "gsdlconf.h"
|
---|
18 | #include "text_t.h"
|
---|
19 | #include "comtypes.h"
|
---|
20 | #include "filter.h"
|
---|
21 | #include "infodbclass.h"
|
---|
22 | #include "maptools.h"
|
---|
23 | #include "mgsearch.h"
|
---|
24 | #include "queryinfo.h"
|
---|
25 |
|
---|
26 |
|
---|
27 | // resultsorderer_t is used to sort the query results
|
---|
28 | struct resultsorderer_t {
|
---|
29 | bool compare_phrase_match;
|
---|
30 | bool compare_terms_match;
|
---|
31 | bool compare_doc_weight;
|
---|
32 | docresultmap *docset;
|
---|
33 |
|
---|
34 | resultsorderer_t();
|
---|
35 | void clear();
|
---|
36 | bool operator()(const int &t1, const int &t2) const;
|
---|
37 | };
|
---|
38 |
|
---|
39 |
|
---|
40 |
|
---|
41 | class queryfilterclass : public filterclass {
|
---|
42 | protected:
|
---|
43 |
|
---|
44 | stringmap indexmap;
|
---|
45 | stringmap subcollectionmap;
|
---|
46 | stringmap languagemap;
|
---|
47 |
|
---|
48 | text_t gdbm_filename;
|
---|
49 | gdbmclass *gdbmptr;
|
---|
50 |
|
---|
51 | mgsearchclass *mgsearchptr;
|
---|
52 |
|
---|
53 | // do aditional query processing
|
---|
54 | virtual void post_process (const queryparamclass &queryparams,
|
---|
55 | queryresultsclass &queryresults);
|
---|
56 |
|
---|
57 | // get the query parameters
|
---|
58 | void parse_query_params (const FilterRequest_t &request,
|
---|
59 | vector<queryparamclass> &query_params,
|
---|
60 | int &startresults,
|
---|
61 | int &endresults,
|
---|
62 | ostream &logout);
|
---|
63 |
|
---|
64 | // do query that might involve multiple sub queries
|
---|
65 | // mgsearchptr and gdbmptr are assumed to be valid
|
---|
66 | void do_multi_query (const FilterRequest_t &request,
|
---|
67 | const vector<queryparamclass> &query_params,
|
---|
68 | queryresultsclass &multiresults,
|
---|
69 | comerror_t &err, ostream &logout);
|
---|
70 |
|
---|
71 | virtual void sort_doc_results (const FilterRequest_t &request,
|
---|
72 | docresultsclass &docs);
|
---|
73 |
|
---|
74 |
|
---|
75 | public:
|
---|
76 | queryfilterclass ();
|
---|
77 | virtual ~queryfilterclass ();
|
---|
78 |
|
---|
79 | // the gdbmptr remains the responsability of the calling code
|
---|
80 | void set_gdbmptr (gdbmclass *thegdbmptr) {gdbmptr=thegdbmptr;}
|
---|
81 |
|
---|
82 | // the mgsearchptr remains the responsability of the calling code
|
---|
83 | void set_mgsearchptr (mgsearchclass *themgsearchptr) {mgsearchptr=themgsearchptr;}
|
---|
84 |
|
---|
85 | void configure (const text_t &key, const text_tarray &cfgline);
|
---|
86 | bool init (ostream &logout);
|
---|
87 | text_t get_filter_name () {return "QueryFilter";}
|
---|
88 | void filter (const FilterRequest_t &request,
|
---|
89 | FilterResponse_t &response,
|
---|
90 | comerror_t &err, ostream &logout);
|
---|
91 | };
|
---|
92 |
|
---|
93 |
|
---|
94 | #endif
|
---|