add "soft" term expansion limit not causing error when reached
This commit is contained in:
parent
1539fe7e4d
commit
d2fbc7f53d
2 changed files with 22 additions and 7 deletions
|
@ -564,6 +564,14 @@ bool SearchDataClauseSimple::expandTerm(Rcl::Db &db,
|
||||||
if (term.empty())
|
if (term.empty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
bool maxexpissoft = false;
|
||||||
|
int maxexpand = getSoftMaxExp();
|
||||||
|
if (maxexpand != -1) {
|
||||||
|
maxexpissoft = true;
|
||||||
|
} else {
|
||||||
|
maxexpand = getMaxExp();
|
||||||
|
}
|
||||||
|
|
||||||
bool haswild = term.find_first_of(cstr_minwilds) != string::npos;
|
bool haswild = term.find_first_of(cstr_minwilds) != string::npos;
|
||||||
|
|
||||||
// If there are no wildcards, add term to the list of user-entered terms
|
// If there are no wildcards, add term to the list of user-entered terms
|
||||||
|
@ -644,7 +652,7 @@ bool SearchDataClauseSimple::expandTerm(Rcl::Db &db,
|
||||||
// would be nothing to prevent us to expand from the casediac
|
// would be nothing to prevent us to expand from the casediac
|
||||||
// synonyms first. To be done later
|
// synonyms first. To be done later
|
||||||
db.termMatch(Rcl::Db::ET_WILD, getStemLang(), term, res,
|
db.termMatch(Rcl::Db::ET_WILD, getStemLang(), term, res,
|
||||||
getMaxExp(), m_field);
|
maxexpand, m_field);
|
||||||
goto termmatchtoresult;
|
goto termmatchtoresult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,7 +661,7 @@ bool SearchDataClauseSimple::expandTerm(Rcl::Db &db,
|
||||||
#ifdef RCL_INDEX_STRIPCHARS
|
#ifdef RCL_INDEX_STRIPCHARS
|
||||||
|
|
||||||
db.termMatch(Rcl::Db::ET_STEM, getStemLang(), term, res,
|
db.termMatch(Rcl::Db::ET_STEM, getStemLang(), term, res,
|
||||||
getMaxExp(), m_field);
|
maxexpand, m_field);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -661,7 +669,7 @@ bool SearchDataClauseSimple::expandTerm(Rcl::Db &db,
|
||||||
// If the index is raw, we can only come here if nostemexp is unset
|
// If the index is raw, we can only come here if nostemexp is unset
|
||||||
// and we just need stem expansion.
|
// and we just need stem expansion.
|
||||||
db.termMatch(Rcl::Db::ET_STEM, getStemLang(), term, res,
|
db.termMatch(Rcl::Db::ET_STEM, getStemLang(), term, res,
|
||||||
getMaxExp(), m_field);
|
maxexpand, m_field);
|
||||||
goto termmatchtoresult;
|
goto termmatchtoresult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -731,13 +739,13 @@ exptotermatch:
|
||||||
for (vector<string>::const_iterator it = lexp.begin();
|
for (vector<string>::const_iterator it = lexp.begin();
|
||||||
it != lexp.end(); it++) {
|
it != lexp.end(); it++) {
|
||||||
db.termMatch(Rcl::Db::ET_WILD, getStemLang(), *it, res,
|
db.termMatch(Rcl::Db::ET_WILD, getStemLang(), *it, res,
|
||||||
getMaxExp(), m_field);
|
maxexpand, m_field);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Term match entries to vector of terms
|
// Term match entries to vector of terms
|
||||||
termmatchtoresult:
|
termmatchtoresult:
|
||||||
if (int(res.entries.size()) >= getMaxExp()) {
|
if (int(res.entries.size()) >= maxexpand && !maxexpissoft) {
|
||||||
ermsg = "Maximum term expansion size exceeded."
|
ermsg = "Maximum term expansion size exceeded."
|
||||||
" Maybe increase maxTermExpand.";
|
" Maybe increase maxTermExpand.";
|
||||||
return false;
|
return false;
|
||||||
|
@ -1140,9 +1148,11 @@ bool SearchDataClauseFilename::toNativeQuery(Rcl::Db &db, void *p)
|
||||||
Xapian::Query *qp = (Xapian::Query *)p;
|
Xapian::Query *qp = (Xapian::Query *)p;
|
||||||
*qp = Xapian::Query();
|
*qp = Xapian::Query();
|
||||||
|
|
||||||
|
int maxexp = getSoftMaxExp();
|
||||||
|
if (maxexp == -1)
|
||||||
|
maxexp = getMaxExp();
|
||||||
|
|
||||||
vector<string> names;
|
vector<string> names;
|
||||||
int maxexp = 10000;
|
|
||||||
db.getConf()->getConfParam("maxTermExpand", &maxexp);
|
|
||||||
db.filenameWildExp(m_text, names, maxexp);
|
db.filenameWildExp(m_text, names, maxexp);
|
||||||
*qp = Xapian::Query(Xapian::Query::OP_OR, names.begin(), names.end());
|
*qp = Xapian::Query(Xapian::Query::OP_OR, names.begin(), names.end());
|
||||||
|
|
||||||
|
|
|
@ -168,6 +168,7 @@ public:
|
||||||
bool getAutoCase() {return m_autocasesens;}
|
bool getAutoCase() {return m_autocasesens;}
|
||||||
int getMaxExp() {return m_maxexp;}
|
int getMaxExp() {return m_maxexp;}
|
||||||
int getMaxCl() {return m_maxcl;}
|
int getMaxCl() {return m_maxcl;}
|
||||||
|
int getSoftMaxExp() {return m_softmaxexpand;}
|
||||||
|
|
||||||
friend class ::AdvSearch;
|
friend class ::AdvSearch;
|
||||||
|
|
||||||
|
@ -276,6 +277,10 @@ public:
|
||||||
{
|
{
|
||||||
return m_parentSearch ? m_parentSearch->getMaxCl() : 100000;
|
return m_parentSearch ? m_parentSearch->getMaxCl() : 100000;
|
||||||
}
|
}
|
||||||
|
int getSoftMaxExp()
|
||||||
|
{
|
||||||
|
return m_parentSearch ? m_parentSearch->getSoftMaxExp() : -1;
|
||||||
|
}
|
||||||
virtual void setModifiers(Modifier mod)
|
virtual void setModifiers(Modifier mod)
|
||||||
{
|
{
|
||||||
m_modifiers = mod;
|
m_modifiers = mod;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue