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

Last change on this file since 12770 was 12770, checked in by mdewsnip, 18 years ago

Changed the Lucene "-fuzzy" argument to "-fuzziness <value>", for more accurate control.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 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 filterstring; // Filter specified (currently only used by Lucene)
69 text_t sortfield; // Field to use for sorting result set (currently used by lucene)
70 text_t fuzziness; // Search fuzziness amount between 0.0 and 1.0 (only used by Lucene)
71
72 int startresults;
73 int endresults;
74
75 queryparamclass ();
76 void clear ();
77 queryparamclass &operator=(const queryparamclass &q);
78};
79
80bool operator==(const queryparamclass &x, const queryparamclass &y);
81bool operator!=(const queryparamclass &x, const queryparamclass &y);
82
83// stream output for debugging purposes
84ostream &operator<< (ostream &outs, queryparamclass &q);
85
86
87
88// term frequencies
89
90struct termfreqclass {
91 text_t termstr;
92 text_t termstemstr;
93 text_tset utf8equivterms; // kept as utf8 string for fast matching
94 unsigned int termfreq;
95
96 termfreqclass ();
97 void clear();
98 termfreqclass &operator=(const termfreqclass &t);
99};
100
101typedef vector<termfreqclass> termfreqclassarray;
102
103bool operator==(const termfreqclass &x, const termfreqclass &y);
104bool operator!=(const termfreqclass &x, const termfreqclass &y);
105bool operator<(const termfreqclass &x, const termfreqclass &y);
106bool operator>(const termfreqclass &x, const termfreqclass &y);
107
108// stream output for debugging purposes
109ostream &operator<< (ostream &outs, termfreqclass &q);
110
111
112
113// one query result
114
115struct docresultclass {
116 int docnum;
117 float docweight;
118 unsigned int num_query_terms_matched; // not available on all versions of mg
119 int num_phrase_match; // not available on all versions of mg
120
121 docresultclass();
122 ~docresultclass() {}
123 void clear ();
124
125 // merges two result classes relating to a single docnum
126 docresultclass &combine(const docresultclass &d);
127
128 docresultclass &operator=(const docresultclass &d);
129};
130
131bool operator==(const docresultclass &x, const docresultclass &y);
132bool operator<(const docresultclass &x, const docresultclass &y);
133
134
135// stream output for debugging purposes
136ostream &operator<< (ostream &outs, docresultclass &a);
137
138
139struct ltint {
140 bool operator()(const int &t1, const int &t2) const
141 { return t1 < t2; }
142};
143
144typedef map<int, docresultclass, ltint> docresultmap;
145
146
147
148// many document results
149
150struct docresultsclass {
151 docresultmap docset;
152 vector<int> docorder;
153
154 docresultsclass ();
155 void clear ();
156 void docnum_order();
157
158 void combine_and (const docresultsclass &d);
159 void combine_or (const docresultsclass &d);
160 void combine_not (const docresultsclass &d);
161
162 docresultsclass &operator=(const docresultsclass &d);
163};
164
165
166
167
168// query results
169
170struct queryresultsclass {
171 queryresultsclass () {clear();}
172
173 text_t error_message; // Currently only used by Lucene
174 int docs_matched; // not available on all versions of mg
175 isapprox is_approx;
176 // bool is_approx; // not available on all versions of mg
177 bool syntax_error; // whether the query string was invalid
178 bool postprocessed; // whether this record has been post-processed
179
180 docresultsclass docs;
181 termfreqclassarray orgterms; // terms before they are sorted and uniqued
182 termfreqclassarray terms;
183 text_tset termvariants;
184 text_tset stopwords;
185
186 void clear ();
187 queryresultsclass &operator=(const queryresultsclass &q);
188
189 void sortuniqqueryterms();
190};
191
192// stream output for debugging purposes
193ostream &operator<< (ostream &outs, queryresultsclass &q);
194
195
196#endif
Note: See TracBrowser for help on using the repository browser.