move stemlang from RclQuery to SearchData. Allow DocSequences to do the sorting/filtering themselves

This commit is contained in:
dockes
2008-09-29 11:33:55 +00:00
parent 828dff3bb1
commit f0538b15f2
16 changed files with 166 additions and 97 deletions
+3 -6
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rclquery.cpp,v 1.8 2008-09-29 08:59:20 dockes Exp $ (C) 2008 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclquery.cpp,v 1.9 2008-09-29 11:33:55 dockes Exp $ (C) 2008 J.F.Dockes";
#endif
#include <stdlib.h>
@@ -124,8 +124,7 @@ void Query::setSortBy(const string& fld, bool ascending) {
#define ISNULL(X) !(X)
// Prepare query out of user search data
bool Query::setQuery(RefCntr<SearchData> sdata, int opts,
const string& stemlang)
bool Query::setQuery(RefCntr<SearchData> sdata)
{
LOGDEB(("Query::setQuery:\n"));
@@ -136,7 +135,6 @@ bool Query::setQuery(RefCntr<SearchData> sdata, int opts,
m_reason.erase();
m_filterTopDir = sdata->getTopdir();
m_qOpts = opts;
m_nq->clear();
if (!m_filterTopDir.empty()) {
@@ -149,8 +147,7 @@ bool Query::setQuery(RefCntr<SearchData> sdata, int opts,
}
Xapian::Query xq;
if (!sdata->toNativeQuery(*m_db, &xq, (opts & QO_STEM) ?
stemlang : string())) {
if (!sdata->toNativeQuery(*m_db, &xq)) {
m_reason += sdata->getReason();
return false;
}
+2 -6
View File
@@ -1,6 +1,6 @@
#ifndef _rclquery_h_included_
#define _rclquery_h_included_
/* @(#$Id: rclquery.h,v 1.5 2008-09-29 08:59:20 dockes Exp $ (C) 2008 J.F.Dockes */
/* @(#$Id: rclquery.h,v 1.6 2008-09-29 11:33:55 dockes Exp $ (C) 2008 J.F.Dockes */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -45,8 +45,6 @@ class Doc;
*/
class Query {
public:
enum QueryOpts {QO_NONE=0, QO_STEM = 1};
/** The constructor only allocates memory */
Query(Db *db);
~Query();
@@ -63,8 +61,7 @@ class Query {
* be called repeatedly on the same object which gets reinitialized each
* time.
*/
bool setQuery(RefCntr<SearchData> q, int opts = QO_NONE,
const string& stemlang = "english");
bool setQuery(RefCntr<SearchData> q);
/** Get results count for current query */
int getResCnt();
@@ -93,7 +90,6 @@ private:
string m_reason; // Error explanation
Db *m_db;
void *m_sorter;
unsigned int m_qOpts;
string m_sortField;
bool m_sortAscending;
/* Copyconst and assignement private and forbidden */
+5 -6
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: searchdata.cpp,v 1.24 2008-09-29 06:58:25 dockes Exp $ (C) 2006 J.F.Dockes";
static char rcsid[] = "@(#$Id: searchdata.cpp,v 1.25 2008-09-29 11:33:55 dockes Exp $ (C) 2006 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -43,7 +43,7 @@ namespace Rcl {
typedef vector<SearchDataClause *>::iterator qlist_it_t;
typedef vector<SearchDataClause *>::const_iterator qlist_cit_t;
bool SearchData::toNativeQuery(Rcl::Db &db, void *d, const string& stemlang)
bool SearchData::toNativeQuery(Rcl::Db &db, void *d)
{
Xapian::Query xq;
m_reason.erase();
@@ -74,7 +74,7 @@ bool SearchData::toNativeQuery(Rcl::Db &db, void *d, const string& stemlang)
// Xapian query tree
for (qlist_it_t it = m_query.begin(); it != m_query.end(); it++) {
Xapian::Query nq;
if (!(*it)->toNativeQuery(db, &nq, stemlang)) {
if (!(*it)->toNativeQuery(db, &nq, m_stemlang)) {
LOGERR(("SearchData::toNativeQuery: failed\n"));
m_reason = (*it)->getReason();
return false;
@@ -631,10 +631,9 @@ bool SearchDataClauseDist::toNativeQuery(Rcl::Db &db, void *p,
}
// Translate subquery
bool SearchDataClauseSub::toNativeQuery(Rcl::Db &db, void *p,
const string& stemlang)
bool SearchDataClauseSub::toNativeQuery(Rcl::Db &db, void *p, const string&)
{
return m_sub->toNativeQuery(db, p, stemlang);
return m_sub->toNativeQuery(db, p);
}
} // Namespace Rcl
+4 -3
View File
@@ -16,7 +16,7 @@
*/
#ifndef _SEARCHDATA_H_INCLUDED_
#define _SEARCHDATA_H_INCLUDED_
/* @(#$Id: searchdata.h,v 1.19 2008-09-29 06:58:25 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: searchdata.h,v 1.20 2008-09-29 11:33:55 dockes Exp $ (C) 2004 J.F.Dockes */
/**
* Structures to hold data coming almost directly from the gui
@@ -83,7 +83,7 @@ public:
bool haveWildCards() {return m_haveWildCards;}
/** Translate to Xapian query. rcldb knows about the void* */
bool toNativeQuery(Rcl::Db &db, void *, const string& stemlang);
bool toNativeQuery(Rcl::Db &db, void *);
/** We become the owner of cl and will delete it */
bool addClause(SearchDataClause *cl);
@@ -109,7 +109,7 @@ public:
void setTopdir(const string& t) {m_topdir = t;}
/** Add file type for filtering results */
void addFiletype(const string& ft) {m_filetypes.push_back(ft);}
void setStemlang(const string& lang = "english") {m_stemlang = lang;}
private:
SClType m_tp; // Only SCLT_AND or SCLT_OR here
vector<SearchDataClause*> m_query;
@@ -120,6 +120,7 @@ private:
string m_description;
string m_reason;
bool m_haveWildCards;
string m_stemlang;
/* Copyconst and assignment private and forbidden */
SearchData(const SearchData &) {}
SearchData& operator=(const SearchData&) {return *this;};