allow wild chars in dir clauses

This commit is contained in:
Jean-Francois Dockes 2013-04-01 16:01:21 +02:00
parent 1574eb459b
commit dd42a9f51e
4 changed files with 47 additions and 28 deletions

View file

@ -917,6 +917,10 @@ bool Db::addOrUpdate(const string &udi, const string &parent_udi, Doc &doc)
string path = url_gpath(doc.url); string path = url_gpath(doc.url);
vector<string> vpath; vector<string> vpath;
stringToTokens(path, vpath, "/"); stringToTokens(path, vpath, "/");
// If vpath is not /, the last elt is the file/dir name, not a
// part of the path.
if (vpath.size())
vpath.resize(vpath.size()-1);
splitter.curpos = 0; splitter.curpos = 0;
newdocument.add_posting(wrap_prefix(pathelt_prefix), newdocument.add_posting(wrap_prefix(pathelt_prefix),
splitter.basepos + splitter.curpos++); splitter.basepos + splitter.curpos++);

View file

@ -517,7 +517,7 @@ static void listVector(const string& what, const vector<string>&l)
for (vector<string>::const_iterator it = l.begin(); it != l.end(); it++) { for (vector<string>::const_iterator it = l.begin(); it != l.end(); it++) {
a = a + *it + " "; a = a + *it + " ";
} }
LOGDEB(("%s: %s\n", what.c_str(), a.c_str())); LOGDEB0(("%s: %s\n", what.c_str(), a.c_str()));
} }
#endif #endif
@ -1056,19 +1056,42 @@ bool SearchDataClausePath::toNativeQuery(Rcl::Db &db, void *p)
if (m_text.empty()) { if (m_text.empty()) {
LOGERR(("SearchDataClausePath: empty path??\n")); LOGERR(("SearchDataClausePath: empty path??\n"));
m_reason = "Empty path ?";
return false; return false;
} }
vector<Xapian::Query> orqueries;
if (m_text[0] == '/')
orqueries.push_back(Xapian::Query(wrap_prefix(pathelt_prefix)));
vector<string> vpath; vector<string> vpath;
stringToTokens(m_text, vpath, "/"); stringToTokens(m_text, vpath, "/");
vector<string> pvpath;
if (m_text[0] == '/')
pvpath.push_back(wrap_prefix(pathelt_prefix));
for (vector<string>::const_iterator pit = vpath.begin(); for (vector<string>::const_iterator pit = vpath.begin();
pit != vpath.end(); pit++){ pit != vpath.end(); pit++){
pvpath.push_back(wrap_prefix(pathelt_prefix) + *pit);
string sterm;
vector<string> exp;
if (!expandTerm(db, m_reason,
SDCM_NOSTEMMING|SDCM_CASESENS|SDCM_DIACSENS,
*pit, exp, sterm, wrap_prefix(pathelt_prefix))) {
return false;
} }
LOGDEB0(("SDataPath::toNative: exp size %d\n", exp.size()));
listVector("", exp);
if (exp.size() == 1)
orqueries.push_back(Xapian::Query(exp[0]));
else
orqueries.push_back(Xapian::Query(Xapian::Query::OP_OR,
exp.begin(), exp.end()));
m_curcl += exp.size();
if (m_curcl >= getMaxCl())
return false;
}
*qp = Xapian::Query(Xapian::Query::OP_PHRASE, *qp = Xapian::Query(Xapian::Query::OP_PHRASE,
pvpath.begin(), pvpath.end()); orqueries.begin(), orqueries.end());
if (m_weight != 1.0) { if (m_weight != 1.0) {
*qp = Xapian::Query(Xapian::Query::OP_SCALE_WEIGHT, *qp, m_weight); *qp = Xapian::Query(Xapian::Query::OP_SCALE_WEIGHT, *qp, m_weight);

View file

@ -409,10 +409,10 @@ protected:
* change but is no important enough to warrant it, this has to wait for * change but is no important enough to warrant it, this has to wait for
* the next format change. * the next format change.
*/ */
class SearchDataClausePath : public SearchDataClause { class SearchDataClausePath : public SearchDataClauseSimple {
public: public:
SearchDataClausePath(const std::string& txt, bool excl = false) SearchDataClausePath(const std::string& txt, bool excl = false)
: SearchDataClause(SCLT_PATH), m_text(txt) : SearchDataClauseSimple(SCLT_PATH, txt, "dir")
{ {
m_exclude = excl; m_exclude = excl;
m_haveWildCards = false; m_haveWildCards = false;
@ -427,13 +427,7 @@ public:
} }
virtual bool toNativeQuery(Rcl::Db &, void *); virtual bool toNativeQuery(Rcl::Db &, void *);
virtual const std::string& gettext() const
{
return m_text;
}
protected:
std::string m_text;
}; };
/** /**

View file

@ -33,20 +33,18 @@
# The following ones are probably hard-coded in the c code, can't change at # The following ones are probably hard-coded in the c code, can't change at
# all. # all.
# Also reserved: F(parentid), Q(uniqueid) # Also reserved: F(parentid), Q(uniqueid)
title = S ; wdfinc = 10
author = A author = A
abstract = XS
caption = S
title = S
subject = S
keywords= K
xapyear = Y
xapyearmon = M
xapdate = D xapdate = D
keywords= K
xapyearmon = M
title = S ; wdfinc = 10
mtype = T mtype = T
rclUnsplitFN = XSFS
filename = XSFN
ext = XE ext = XE
dir = XP
abstract = XS
filename = XSFN
rclUnsplitFN = XSFS
xapyear = Y
# Extension examples. These are actually used by default by Recoll, you can # Extension examples. These are actually used by default by Recoll, you can
# add your own to search for fields produced by the filters and not handled # add your own to search for fields produced by the filters and not handled
@ -72,13 +70,13 @@ recipient = XTO
# "rclaptg" is used for viewer specialization (depending on local config) # "rclaptg" is used for viewer specialization (depending on local config)
# "rclbes" defines the backend type (ie normal fs, firefox cache). Should # "rclbes" defines the backend type (ie normal fs, firefox cache). Should
# probably be hardcoded, don't remove it # probably be hardcoded, don't remove it
abstract=
author= author=
recipient=
rclaptg=
rclbes=
filename= filename=
keywords= keywords=
abstract= rclaptg=
rclbes=
recipient=
[aliases] [aliases]
########################## ##########################