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 b8778f655e
commit ec99c6bf51
7 changed files with 37 additions and 22 deletions

View file

@ -293,6 +293,9 @@ void AdvSearch::fillFileTypes()
QStringList ql;
if (m_ignByCats == false) {
vector<string> types = theconfig->getAllMimeTypes();
rcldb->getAllDbMimeTypes(types);
sort(types.begin(), types.end());
types.erase(unique(types.begin(), types.end()), types.end());
for (vector<string>::iterator it = types.begin();
it != types.end(); it++) {
QString qs = QString::fromUtf8(it->c_str());

View file

@ -1108,24 +1108,17 @@ void RclMain::showActiveTypes()
return;
}
// Get list of all mime types in index. For this, we use a
// wildcard field search on mtype
Rcl::TermMatchResult matches;
if (!rcldb->termMatch(Rcl::Db::ET_WILD, "", "*", matches, -1, "mtype")) {
// All mime types in index.
vector<string> vdbtypes;
if (!rcldb->getAllDbMimeTypes(vdbtypes)) {
QMessageBox::warning(0, tr("Error"),
tr("Index query error"),
QMessageBox::Ok,
QMessageBox::NoButton);
return;
}
// Build the set of mtypes, stripping the prefix
set<string> mtypesfromdb;
for (vector<Rcl::TermMatchEntry>::const_iterator it =
matches.entries.begin();
it != matches.entries.end(); it++) {
mtypesfromdb.insert(it->term.substr(matches.prefix.size()));
}
mtypesfromdb.insert(vdbtypes.begin(), vdbtypes.end());
// All types listed in mimeconf:
vector<string> mtypesfromconfig = theconfig->getAllMimeTypes();

View file

@ -352,16 +352,13 @@ int SSearch::partialWord(string& s)
}
// Create completion list for term by adding a joker at the end and calling
// rcldb->termMatch(). This does not work well if the db is not
// rcldb->stripped, the completion is casediac-sensitive in this case.
//
// What we should do instead is complete the term from the key list in
// the casediac expansion db (stripped->unstripped synonyms table),
// then expand each of the completed keys.
// rcldb->termMatch().
int SSearch::completionList(string s, QStringList& lst, int max)
{
if (!rcldb)
return -1;
if (s.empty())
return 0;
// Query database for completions
s += "*";
Rcl::TermMatchResult tmres;

View file

@ -22,7 +22,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>3</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -284,6 +284,9 @@
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>9999</number>
</property>
<property name="value">
<number>8</number>
</property>

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);

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) {

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 {