make sure that expansions of * done to retrieve all years or all mime types from index are done against the appropriate field section of the main index, not the whole synexpand one

This commit is contained in:
Jean-Francois Dockes
2013-04-13 16:34:09 +02:00
parent 324f878583
commit aaa98a1156
7 changed files with 37 additions and 22 deletions
+4
View File
@@ -329,6 +329,10 @@ class Db {
bool dbStats(DbStats& stats);
/** Return min and max years for doc mod times in db */
bool maxYearSpan(int *minyear, int *maxyear);
/** Return all mime types in index. This can be different from the
ones defined in the config because of 'file' command
usage. Inserts the types at the end of the parameter */
bool getAllDbMimeTypes(std::vector<std::string>&);
/** Wildcard expansion specific to file names. Internal/sdata use only */
bool filenameWildExp(const string& exp, vector<string>& names, int max);
+16 -3
View File
@@ -59,8 +59,8 @@ bool Db::filenameWildExp(const string& fnexp, vector<string>& names, int max)
}
TermMatchResult result;
if (!termMatch(ET_WILD, string(), pattern, result, max,
unsplitFilenameFieldName))
if (!idxTermMatch(ET_WILD, string(), pattern, result, max,
unsplitFilenameFieldName))
return false;
for (vector<TermMatchEntry>::const_iterator it = result.entries.begin();
it != result.entries.end(); it++)
@@ -81,7 +81,7 @@ bool Db::maxYearSpan(int *minyear, int *maxyear)
*minyear = 1000000;
*maxyear = -1000000;
TermMatchResult result;
if (!termMatch(ET_WILD, string(), "*", result, -1, "xapyear")) {
if (!idxTermMatch(ET_WILD, string(), "*", result, -1, "xapyear")) {
LOGINFO(("Rcl::Db:maxYearSpan: termMatch failed\n"));
return false;
}
@@ -98,6 +98,19 @@ bool Db::maxYearSpan(int *minyear, int *maxyear)
return true;
}
bool Db::getAllDbMimeTypes(std::vector<std::string>& exp)
{
Rcl::TermMatchResult res;
if (!idxTermMatch(Rcl::Db::ET_WILD, "", "*", res, -1, "mtype")) {
return false;
}
for (vector<Rcl::TermMatchEntry>::const_iterator rit = res.entries.begin();
rit != res.entries.end(); rit++) {
exp.push_back(Rcl::strip_prefix(rit->term));
}
return true;
}
class TermMatchCmpByWcf {
public:
int operator()(const TermMatchEntry& l, const TermMatchEntry& r) {
+3 -1
View File
@@ -87,7 +87,9 @@ bool SearchData::expandFileTypes(Db &db, vector<string>& tps)
} else {
TermMatchResult res;
string mt = stringtolower((const string&)*it);
db.termMatch(Db::ET_WILD, "", mt, res, -1, "mtype");
// We set casesens|diacsens to get an equivalent of ixTermMatch()
db.termMatch(Db::ET_WILD|Db::ET_CASESENS|Db::ET_DIACSENS, string(),
mt, res, -1, "mtype");
if (res.entries.empty()) {
exptps.push_back(it->c_str());
} else {