source: trunk/gsdl/src/colservr/queryinfo.h@ 12276

Last change on this file since 12276 was 12276, checked in by sjboddie, 18 years ago

Added "Sort Field" (sf) argument that can be passed through to a lucene
collection to sort search results by a metadata field.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 KB
Line 
1/**********************************************************************
2 *
3 * queryinfo.h --
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 *********************************************************************/
25
26
27#ifndef QUERYINFO_H
28#define QUERYINFO_H
29
30
31#include "gsdlconf.h"
32#include "text_t.h"
33#include "comtypes.h"
34
35#if defined(GSDL_USE_OBJECTSPACE)
36# include <ospace\std\vector>
37# include <ospace\std\algorithm>
38#elif defined(GSDL_USE_STL_H)
39# include <vector.h>
40# if defined(GSDL_USE_ALGO_H)
41# include <algo.h>
42# else
43# include <algorithm.h>
44# endif
45#else
46# include <vector>
47# include <algorithm>
48#endif
49
50// query parameters
51
52struct queryparamclass {
53 text_t combinequery;
54 text_t collection;
55
56 // search_index = index+subcollection+language
57 text_t index;
58 text_t subcollection;
59 text_t language;
60 text_t level; // for new mg stuff
61 text_t querystring;
62 int search_type; // 0 = boolean, 1 = ranked
63 int match_mode; // 0 = some, 1 = all
64 int casefolding;
65 int stemming;
66 int maxdocs;
67 int maxnumeric;
68 text_t sortfield; // Field to use for sorting result set (currently used by lucene)
69
70 queryparamclass ();
71 void clear ();
72 queryparamclass &operator=(const queryparamclass &q);
73};
74
75bool operator==(const queryparamclass &x, const queryparamclass &y);
76bool operator!=(const queryparamclass &x, const queryparamclass &y);
77
78// stream output for debugging purposes
79ostream &operator<< (ostream &outs, queryparamclass &q);
80
81
82
83// term frequencies
84
85struct termfreqclass {
86 text_t termstr;
87 text_t termstemstr;
88 text_tset utf8equivterms; // kept as utf8 string for fast matching
89 unsigned int termfreq;
90
91 termfreqclass ();
92 void clear();
93 termfreqclass &operator=(const termfreqclass &t);
94};
95
96typedef vector<termfreqclass> termfreqclassarray;
97
98bool operator==(const termfreqclass &x, const termfreqclass &y);
99bool operator!=(const termfreqclass &x, const termfreqclass &y);
100bool operator<(const termfreqclass &x, const termfreqclass &y);
101bool operator>(const termfreqclass &x, const termfreqclass &y);
102
103// stream output for debugging purposes
104ostream &operator<< (ostream &outs, termfreqclass &q);
105
106
107
108// one query result
109
110struct docresultclass {
111 int docnum;
112 float docweight;
113 unsigned int num_query_terms_matched; // not available on all versions of mg
114 int num_phrase_match; // not available on all versions of mg
115
116 docresultclass();
117 ~docresultclass() {}
118 void clear ();
119
120 // merges two result classes relating to a single docnum
121 docresultclass &combine(const docresultclass &d);
122
123 docresultclass &operator=(const docresultclass &d);
124};
125
126bool operator==(const docresultclass &x, const docresultclass &y);
127bool operator<(const docresultclass &x, const docresultclass &y);
128
129
130// stream output for debugging purposes
131ostream &operator<< (ostream &outs, docresultclass &a);
132
133
134struct ltint {
135 bool operator()(const int &t1, const int &t2) const
136 { return t1 < t2; }
137};
138
139typedef map<int, docresultclass, ltint> docresultmap;
140
141
142
143// many document results
144
145struct docresultsclass {
146 docresultmap docset;
147 vector<int> docorder;
148
149 docresultsclass ();
150 void clear ();
151 void docnum_order();
152
153 void combine_and (const docresultsclass &d);
154 void combine_or (const docresultsclass &d);
155 void combine_not (const docresultsclass &d);
156
157 docresultsclass &operator=(const docresultsclass &d);
158};
159
160
161
162
163// query results
164
165struct queryresultsclass {
166 queryresultsclass () {clear();}
167
168 int docs_matched; // not available on all versions of mg
169 isapprox is_approx;
170 // bool is_approx; // not available on all versions of mg
171 bool syntax_error; // whether the query string was invalid
172 bool postprocessed; // whether this record has been post-processed
173
174 docresultsclass docs;
175 termfreqclassarray orgterms; // terms before they are sorted and uniqued
176 termfreqclassarray terms;
177 text_tset termvariants;
178
179 void clear ();
180 queryresultsclass &operator=(const queryresultsclass &q);
181
182 void sortuniqqueryterms();
183};
184
185// stream output for debugging purposes
186ostream &operator<< (ostream &outs, queryresultsclass &q);
187
188
189#endif
Note: See TracBrowser for help on using the repository browser.