|
a/src/rcldb/searchdata.h |
|
b/src/rcldb/searchdata.h |
|
... |
|
... |
100 |
|
100 |
|
101 |
/** Translate to Xapian query. rcldb knows about the void* */
|
101 |
/** Translate to Xapian query. rcldb knows about the void* */
|
102 |
bool toNativeQuery(Rcl::Db &db, void *);
|
102 |
bool toNativeQuery(Rcl::Db &db, void *);
|
103 |
|
103 |
|
104 |
/** We become the owner of cl and will delete it */
|
104 |
/** We become the owner of cl and will delete it */
|
105 |
bool addClause(SearchDataClause *cl);
|
105 |
bool addClause(SearchDataClause* cl);
|
106 |
|
106 |
|
107 |
/** If this is a simple query (one field only, no distance clauses),
|
107 |
/** If this is a simple query (one field only, no distance clauses),
|
108 |
* add phrase made of query terms to query, so that docs containing the
|
108 |
* add phrase made of query terms to query, so that docs containing the
|
109 |
* user terms in order will have higher relevance. This must be called
|
109 |
* user terms in order will have higher relevance. This must be called
|
110 |
* before toNativeQuery().
|
110 |
* before toNativeQuery().
|
|
... |
|
... |
162 |
friend class ::AdvSearch;
|
162 |
friend class ::AdvSearch;
|
163 |
|
163 |
|
164 |
private:
|
164 |
private:
|
165 |
// Combine type. Only SCLT_AND or SCLT_OR here
|
165 |
// Combine type. Only SCLT_AND or SCLT_OR here
|
166 |
SClType m_tp;
|
166 |
SClType m_tp;
|
167 |
// Complex query descriptor
|
167 |
// The clauses
|
168 |
std::vector<SearchDataClause*> m_query;
|
168 |
std::vector<SearchDataClause*> m_query;
|
169 |
// Restricted set of filetypes if not empty.
|
169 |
// Restricted set of filetypes if not empty.
|
170 |
std::vector<std::string> m_filetypes;
|
170 |
std::vector<std::string> m_filetypes;
|
171 |
// Excluded set of file types if not empty
|
171 |
// Excluded set of file types if not empty
|
172 |
std::vector<std::string> m_nfiletypes;
|
172 |
std::vector<std::string> m_nfiletypes;
|
173 |
// Autophrase if set. Can't be part of the normal chain because
|
173 |
// Autophrase if set. Can't be part of the normal chain because
|
174 |
// it uses OP_AND_MAYBE
|
174 |
// it uses OP_AND_MAYBE
|
175 |
RefCntr<SearchDataClauseDist> m_autophrase;
|
175 |
RefCntr<SearchDataClauseDist> m_autophrase;
|
176 |
//
|
176 |
|
|
|
177 |
// Special stuff produced by input which looks like a clause but means
|
|
|
178 |
// something else (date and size specs)
|
177 |
bool m_haveDates;
|
179 |
bool m_haveDates;
|
178 |
DateInterval m_dates; // Restrict to date interval
|
180 |
DateInterval m_dates; // Restrict to date interval
|
179 |
size_t m_maxSize;
|
181 |
size_t m_maxSize;
|
180 |
size_t m_minSize;
|
182 |
size_t m_minSize;
|
|
|
183 |
|
181 |
// Printable expanded version of the complete query, retrieved/set
|
184 |
// Printable expanded version of the complete query, retrieved/set
|
182 |
// from rcldb after the Xapian::setQuery() call
|
185 |
// from rcldb after the Xapian::setQuery() call
|
183 |
std::string m_description;
|
186 |
std::string m_description;
|
|
|
187 |
// Error diag
|
184 |
std::string m_reason;
|
188 |
std::string m_reason;
|
185 |
bool m_haveWildCards;
|
189 |
bool m_haveWildCards;
|
186 |
std::string m_stemlang;
|
190 |
std::string m_stemlang;
|
187 |
|
191 |
|
188 |
// Parameters set at the start of ToNativeQuery because they need
|
192 |
// Parameters set at the start of ToNativeQuery because they need
|
|
... |
|
... |
213 |
|
217 |
|
214 |
class SearchDataClause {
|
218 |
class SearchDataClause {
|
215 |
public:
|
219 |
public:
|
216 |
enum Modifier {SDCM_NONE=0, SDCM_NOSTEMMING=1, SDCM_ANCHORSTART=2,
|
220 |
enum Modifier {SDCM_NONE=0, SDCM_NOSTEMMING=1, SDCM_ANCHORSTART=2,
|
217 |
SDCM_ANCHOREND=4, SDCM_CASESENS=8, SDCM_DIACSENS=16};
|
221 |
SDCM_ANCHOREND=4, SDCM_CASESENS=8, SDCM_DIACSENS=16};
|
|
|
222 |
enum Relation {REL_CONTAINS, REL_EQUALS, REL_LT, REL_LTE, REL_GT, REL_GTE};
|
218 |
|
223 |
|
219 |
SearchDataClause(SClType tp)
|
224 |
SearchDataClause(SClType tp)
|
220 |
: m_tp(tp), m_parentSearch(0), m_haveWildCards(0),
|
225 |
: m_tp(tp), m_parentSearch(0), m_haveWildCards(0),
|
221 |
m_modifiers(SDCM_NONE), m_weight(1.0), m_exclude(false)
|
226 |
m_modifiers(SDCM_NONE), m_weight(1.0), m_exclude(false),
|
|
|
227 |
m_rel(REL_CONTAINS)
|
222 |
{}
|
228 |
{}
|
223 |
virtual ~SearchDataClause() {}
|
229 |
virtual ~SearchDataClause() {}
|
224 |
virtual bool toNativeQuery(Rcl::Db &db, void *) = 0;
|
230 |
virtual bool toNativeQuery(Rcl::Db &db, void *) = 0;
|
225 |
bool isFileName() const {return m_tp == SCLT_FILENAME ? true: false;}
|
231 |
bool isFileName() const {return m_tp == SCLT_FILENAME ? true: false;}
|
226 |
virtual std::string getReason() const {return m_reason;}
|
232 |
virtual std::string getReason() const {return m_reason;}
|
|
... |
|
... |
228 |
|
234 |
|
229 |
SClType getTp() const
|
235 |
SClType getTp() const
|
230 |
{
|
236 |
{
|
231 |
return m_tp;
|
237 |
return m_tp;
|
232 |
}
|
238 |
}
|
|
|
239 |
void setTp(SClType tp) {
|
|
|
240 |
m_tp = tp;
|
|
|
241 |
}
|
233 |
void setParent(SearchData *p)
|
242 |
void setParent(SearchData *p)
|
234 |
{
|
243 |
{
|
235 |
m_parentSearch = p;
|
244 |
m_parentSearch = p;
|
236 |
}
|
245 |
}
|
237 |
string getStemLang()
|
246 |
string getStemLang()
|
|
... |
|
... |
277 |
}
|
286 |
}
|
278 |
virtual void setexclude(bool onoff)
|
287 |
virtual void setexclude(bool onoff)
|
279 |
{
|
288 |
{
|
280 |
m_exclude = onoff;
|
289 |
m_exclude = onoff;
|
281 |
}
|
290 |
}
|
282 |
|
291 |
virtual void setrel(Relation rel) {
|
|
|
292 |
m_rel = rel;
|
|
|
293 |
}
|
|
|
294 |
virtual Relation getrel() {
|
|
|
295 |
return m_rel;
|
|
|
296 |
}
|
283 |
friend class SearchData;
|
297 |
friend class SearchData;
|
284 |
protected:
|
298 |
protected:
|
285 |
std::string m_reason;
|
299 |
std::string m_reason;
|
286 |
SClType m_tp;
|
300 |
SClType m_tp;
|
287 |
SearchData *m_parentSearch;
|
301 |
SearchData *m_parentSearch;
|
288 |
bool m_haveWildCards;
|
302 |
bool m_haveWildCards;
|
289 |
Modifier m_modifiers;
|
303 |
Modifier m_modifiers;
|
290 |
float m_weight;
|
304 |
float m_weight;
|
291 |
bool m_exclude;
|
305 |
bool m_exclude;
|
|
|
306 |
Relation m_rel;
|
|
|
307 |
|
292 |
private:
|
308 |
private:
|
293 |
SearchDataClause(const SearchDataClause&)
|
309 |
SearchDataClause(const SearchDataClause&)
|
294 |
{
|
310 |
{
|
295 |
}
|
311 |
}
|
296 |
SearchDataClause& operator=(const SearchDataClause&)
|
312 |
SearchDataClause& operator=(const SearchDataClause&)
|
|
... |
|
... |
336 |
return m_text;
|
352 |
return m_text;
|
337 |
}
|
353 |
}
|
338 |
virtual const std::string& getfield()
|
354 |
virtual const std::string& getfield()
|
339 |
{
|
355 |
{
|
340 |
return m_field;
|
356 |
return m_field;
|
|
|
357 |
}
|
|
|
358 |
virtual void setfield(const string& field) {
|
|
|
359 |
m_field = field;
|
341 |
}
|
360 |
}
|
342 |
protected:
|
361 |
protected:
|
343 |
std::string m_text; // Raw user entry text.
|
362 |
std::string m_text; // Raw user entry text.
|
344 |
std::string m_field; // Field specification if any
|
363 |
std::string m_field; // Field specification if any
|
345 |
HighlightData m_hldata;
|
364 |
HighlightData m_hldata;
|
346 |
// Current count of Xapian clauses, to check against expansion limit
|
365 |
// Current count of Xapian clauses, to check against expansion limit
|
347 |
int m_curcl;
|
366 |
int m_curcl;
|
348 |
|
|
|
349 |
bool processUserString(Rcl::Db &db, const string &iq,
|
367 |
bool processUserString(Rcl::Db &db, const string &iq,
|
350 |
std::string &ermsg,
|
368 |
std::string &ermsg,
|
351 |
void* pq, int slack = 0, bool useNear = false);
|
369 |
void* pq, int slack = 0, bool useNear = false);
|
352 |
bool expandTerm(Rcl::Db &db, std::string& ermsg, int mods,
|
370 |
bool expandTerm(Rcl::Db &db, std::string& ermsg, int mods,
|
353 |
const std::string& term,
|
371 |
const std::string& term,
|
|
... |
|
... |
442 |
virtual bool toNativeQuery(Rcl::Db &, void *);
|
460 |
virtual bool toNativeQuery(Rcl::Db &, void *);
|
443 |
virtual int getslack() const
|
461 |
virtual int getslack() const
|
444 |
{
|
462 |
{
|
445 |
return m_slack;
|
463 |
return m_slack;
|
446 |
}
|
464 |
}
|
|
|
465 |
virtual void setslack(int slack) {
|
|
|
466 |
m_slack = slack;
|
|
|
467 |
}
|
447 |
private:
|
468 |
private:
|
448 |
int m_slack;
|
469 |
int m_slack;
|
449 |
};
|
470 |
};
|
450 |
|
471 |
|
451 |
/** Subquery */
|
472 |
/** Subquery */
|