handle mime: and ext: in qlang

This commit is contained in:
dockes
2007-06-22 06:14:04 +00:00
parent 2777fedb78
commit e892ca4fa4
6 changed files with 61 additions and 12 deletions
+7 -1
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.117 2007-06-21 11:56:28 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.118 2007-06-22 06:14:04 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -750,6 +750,7 @@ bool Db::fieldToPrefix(const string& fldname, string &pfx)
static map<string, string> fldToPrefs;
if (fldToPrefs.empty()) {
fldToPrefs["abstract"] = "";
fldToPrefs["ext"] = "XE";
fldToPrefs["title"] = "S";
fldToPrefs["caption"] = "S";
@@ -990,7 +991,12 @@ bool Db::add(const string &fn, const Doc &idoc, const struct stat *stp)
// Simple file name. This is used for file name searches only. We index
// it with a term prefix. utf8fn used to be the full path, but it's now
// the simple file name.
// We also add a term for the filename extension if any.
if (dumb_string(doc.utf8fn, noacc) && !noacc.empty()) {
string::size_type pos = noacc.rfind('.');
if (pos != string::npos && pos != noacc.length() -1) {
newdocument.add_term(string("XE") + noacc.substr(pos+1));
}
noacc = string("XSFN") + noacc;
newdocument.add_term(noacc);
}
+18 -3
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: searchdata.cpp,v 1.16 2007-06-19 08:36:24 dockes Exp $ (C) 2006 J.F.Dockes";
static char rcsid[] = "@(#$Id: searchdata.cpp,v 1.17 2007-06-22 06:14:04 dockes Exp $ (C) 2006 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -72,10 +72,25 @@ bool SearchData::toNativeQuery(Rcl::Db &db, void *d, const string& stemlang)
// Add the file type filtering clause if any
if (!m_filetypes.empty()) {
list<Xapian::Query> pqueries;
Xapian::Query tq;
vector<string> exptps;
exptps.reserve(m_filetypes.size());
// Expand categories
RclConfig *cfg = RclConfig::getMainConfig();
for (vector<string>::iterator it = m_filetypes.begin();
it != m_filetypes.end(); it++) {
if (cfg && cfg->isMimeCategory(*it)) {
list<string>tps;
cfg->getMimeCatTypes(*it, tps);
exptps.insert(exptps.end(), tps.begin(), tps.end());
} else {
exptps.push_back(*it);
}
}
list<Xapian::Query> pqueries;
Xapian::Query tq;
for (vector<string>::iterator it = exptps.begin();
it != exptps.end(); it++) {
string term = "T" + *it;
LOGDEB(("Adding file type term: [%s]\n", term.c_str()));
tq = tq.empty() ? Xapian::Query(term) :