Search: allow negative directory filtering (all except from dir). Emit more explicit errors for other unallowed negative search clauses.
This commit is contained in:
@@ -259,9 +259,10 @@ bool SearchData::toNativeQuery(Rcl::Db &db, void *d)
|
||||
it != vpath.end(); it++){
|
||||
pvpath.push_back(pathelt_prefix + *it);
|
||||
}
|
||||
xq = Xapian::Query(Xapian::Query::OP_FILTER, xq,
|
||||
Xapian::Query(Xapian::Query::OP_PHRASE,
|
||||
pvpath.begin(), pvpath.end()));
|
||||
xq = Xapian::Query(m_topdirexcl ?
|
||||
Xapian::Query::OP_AND_NOT:Xapian::Query::OP_FILTER,
|
||||
xq, Xapian::Query(Xapian::Query::OP_PHRASE,
|
||||
pvpath.begin(), pvpath.end()));
|
||||
}
|
||||
|
||||
*((Xapian::Query *)d) = xq;
|
||||
@@ -355,6 +356,7 @@ void SearchData::erase() {
|
||||
m_query.clear();
|
||||
m_filetypes.clear();
|
||||
m_topdir.erase();
|
||||
m_topdirexcl = false;
|
||||
m_description.erase();
|
||||
m_reason.erase();
|
||||
m_haveDates = false;
|
||||
|
||||
@@ -72,7 +72,8 @@ class SearchDataClause;
|
||||
class SearchData {
|
||||
public:
|
||||
SearchData(SClType tp)
|
||||
: m_tp(tp), m_haveDates(false), m_haveWildCards(false)
|
||||
: m_tp(tp), m_topdirexcl(false), m_haveDates(false),
|
||||
m_haveWildCards(false)
|
||||
{
|
||||
if (m_tp != SCLT_OR && m_tp != SCLT_AND)
|
||||
m_tp = SCLT_OR;
|
||||
@@ -102,8 +103,11 @@ public:
|
||||
bool maybeAddAutoPhrase();
|
||||
|
||||
/** Set/get top subdirectory for filtering results */
|
||||
void setTopdir(const string& t) {m_topdir = t;}
|
||||
string getTopdir() {return m_topdir;}
|
||||
void setTopdir(const string& t, bool excl = false)
|
||||
{
|
||||
m_topdir = t;
|
||||
m_topdirexcl = excl;
|
||||
}
|
||||
|
||||
/** Set date span for filtering results */
|
||||
void setDateSpan(DateInterval *dip) {m_dates = *dip; m_haveDates = true;}
|
||||
@@ -138,6 +142,7 @@ private:
|
||||
vector<SearchDataClause*> m_query;
|
||||
vector<string> m_filetypes; // Restrict to filetypes if set.
|
||||
string m_topdir; // Restrict to subtree.
|
||||
bool m_topdirexcl; // Invert meaning
|
||||
bool m_haveDates;
|
||||
DateInterval m_dates; // Restrict to date interval
|
||||
// Printable expanded version of the complete query, retrieved/set
|
||||
|
||||
Reference in New Issue
Block a user