small fixups and compilation issues
This commit is contained in:
parent
a8e4d4734f
commit
1f9e9d200a
5 changed files with 29 additions and 24 deletions
|
@ -1697,7 +1697,7 @@ static void addPrefix(vector<TermMatchEntry>& terms, const string& prefix)
|
||||||
// If field is set, we return a list of appropriately prefixed terms (which
|
// If field is set, we return a list of appropriately prefixed terms (which
|
||||||
// are going to be used to build a Xapian query).
|
// are going to be used to build a Xapian query).
|
||||||
bool Db::termMatch(MatchType typ, const string &lang,
|
bool Db::termMatch(MatchType typ, const string &lang,
|
||||||
const string &root,
|
const string &_root,
|
||||||
TermMatchResult& res,
|
TermMatchResult& res,
|
||||||
int max,
|
int max,
|
||||||
const string& field)
|
const string& field)
|
||||||
|
@ -1714,15 +1714,14 @@ bool Db::termMatch(MatchType typ, const string &lang,
|
||||||
if (!m_reason.empty())
|
if (!m_reason.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Get rid of capitals and accents
|
string droot = _root;
|
||||||
|
|
||||||
string droot = root;
|
|
||||||
|
|
||||||
|
// If index is stripped, get rid of capitals and accents
|
||||||
#ifndef RCL_INDEX_STRIPCHARS
|
#ifndef RCL_INDEX_STRIPCHARS
|
||||||
if (o_index_stripchars)
|
if (o_index_stripchars)
|
||||||
#endif
|
#endif
|
||||||
if (!unacmaybefold(root, droot, "UTF-8", UNACOP_UNACFOLD)) {
|
if (!unacmaybefold(_root, droot, "UTF-8", UNACOP_UNACFOLD)) {
|
||||||
LOGERR(("Db::termMatch: unac failed for [%s]\n", root.c_str()));
|
LOGERR(("Db::termMatch: unac failed for [%s]\n", _root.c_str()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1742,7 +1741,7 @@ bool Db::termMatch(MatchType typ, const string &lang,
|
||||||
res.prefix = prefix;
|
res.prefix = prefix;
|
||||||
|
|
||||||
if (typ == ET_STEM) {
|
if (typ == ET_STEM) {
|
||||||
if (!stemExpand(lang, root, res))
|
if (!stemExpand(lang, droot, res))
|
||||||
return false;
|
return false;
|
||||||
for (vector<TermMatchEntry>::iterator it = res.entries.begin();
|
for (vector<TermMatchEntry>::iterator it = res.entries.begin();
|
||||||
it != res.entries.end(); it++) {
|
it != res.entries.end(); it++) {
|
||||||
|
@ -1759,8 +1758,7 @@ bool Db::termMatch(MatchType typ, const string &lang,
|
||||||
regex_t reg;
|
regex_t reg;
|
||||||
int errcode;
|
int errcode;
|
||||||
if (typ == ET_REGEXP) {
|
if (typ == ET_REGEXP) {
|
||||||
string mroot = droot;
|
if ((errcode = regcomp(®, droot.c_str(),
|
||||||
if ((errcode = regcomp(®, mroot.c_str(),
|
|
||||||
REG_EXTENDED|REG_NOSUB))) {
|
REG_EXTENDED|REG_NOSUB))) {
|
||||||
char errbuf[200];
|
char errbuf[200];
|
||||||
regerror(errcode, ®, errbuf, 199);
|
regerror(errcode, ®, errbuf, 199);
|
||||||
|
|
|
@ -606,10 +606,13 @@ bool SearchDataClauseSimple::expandTerm(Rcl::Db &db,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef RCL_INDEX_STRIPCHARS
|
||||||
// The case/diac expansion db
|
// The case/diac expansion db
|
||||||
SynTermTransUnac unacfoldtrans(UNACOP_UNACFOLD);
|
SynTermTransUnac unacfoldtrans(UNACOP_UNACFOLD);
|
||||||
XapComputableSynFamMember synac(db.m_ndb->xrdb, synFamDiCa, "all",
|
XapComputableSynFamMember synac(db.m_ndb->xrdb, synFamDiCa, "all",
|
||||||
&unacfoldtrans);
|
&unacfoldtrans);
|
||||||
|
#endif // RCL_INDEX_STRIPCHARS
|
||||||
|
|
||||||
TermMatchResult res;
|
TermMatchResult res;
|
||||||
|
|
||||||
if (haswild) {
|
if (haswild) {
|
||||||
|
@ -969,10 +972,11 @@ static int stringToMods(string& s)
|
||||||
* count)
|
* count)
|
||||||
*/
|
*/
|
||||||
bool SearchDataClauseSimple::processUserString(Rcl::Db &db, const string &iq,
|
bool SearchDataClauseSimple::processUserString(Rcl::Db &db, const string &iq,
|
||||||
int mods, string &ermsg,
|
string &ermsg, void *pq,
|
||||||
void *pq, int slack, bool useNear)
|
int slack, bool useNear)
|
||||||
{
|
{
|
||||||
vector<Xapian::Query> &pqueries(*(vector<Xapian::Query>*)pq);
|
vector<Xapian::Query> &pqueries(*(vector<Xapian::Query>*)pq);
|
||||||
|
int mods = m_modifiers;
|
||||||
|
|
||||||
LOGDEB(("StringToXapianQ:pUS:: qstr [%s] fld [%s] mods 0x%x "
|
LOGDEB(("StringToXapianQ:pUS:: qstr [%s] fld [%s] mods 0x%x "
|
||||||
"slack %d near %d\n",
|
"slack %d near %d\n",
|
||||||
|
@ -1094,7 +1098,7 @@ bool SearchDataClauseSimple::toNativeQuery(Rcl::Db &db, void *p)
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<Xapian::Query> pqueries;
|
vector<Xapian::Query> pqueries;
|
||||||
if (!processUserString(db, m_text, getModifiers(), m_reason, &pqueries))
|
if (!processUserString(db, m_text, m_reason, &pqueries))
|
||||||
return false;
|
return false;
|
||||||
if (pqueries.empty()) {
|
if (pqueries.empty()) {
|
||||||
LOGERR(("SearchDataClauseSimple: resolved to null query\n"));
|
LOGERR(("SearchDataClauseSimple: resolved to null query\n"));
|
||||||
|
@ -1185,8 +1189,7 @@ bool SearchDataClauseDist::toNativeQuery(Rcl::Db &db, void *p)
|
||||||
}
|
}
|
||||||
string s = cstr_dquote + m_text + cstr_dquote;
|
string s = cstr_dquote + m_text + cstr_dquote;
|
||||||
bool useNear = (m_tp == SCLT_NEAR);
|
bool useNear = (m_tp == SCLT_NEAR);
|
||||||
if (!processUserString(db, s, getModifiers(), m_reason, &pqueries,
|
if (!processUserString(db, s, m_reason, &pqueries, m_slack, useNear))
|
||||||
m_slack, useNear))
|
|
||||||
return false;
|
return false;
|
||||||
if (pqueries.empty()) {
|
if (pqueries.empty()) {
|
||||||
LOGERR(("SearchDataClauseDist: resolved to null query\n"));
|
LOGERR(("SearchDataClauseDist: resolved to null query\n"));
|
||||||
|
|
|
@ -265,15 +265,9 @@ public:
|
||||||
{
|
{
|
||||||
m_modifiers = mod;
|
m_modifiers = mod;
|
||||||
}
|
}
|
||||||
virtual int getModifiers()
|
|
||||||
{
|
|
||||||
return m_modifiers;
|
|
||||||
}
|
|
||||||
virtual void addModifier(Modifier mod)
|
virtual void addModifier(Modifier mod)
|
||||||
{
|
{
|
||||||
int imod = getModifiers();
|
m_modifiers = Modifier(m_modifiers | mod);
|
||||||
imod |= mod;
|
|
||||||
setModifiers(Modifier(imod));
|
|
||||||
}
|
}
|
||||||
virtual void setWeight(float w)
|
virtual void setWeight(float w)
|
||||||
{
|
{
|
||||||
|
@ -316,7 +310,7 @@ class SearchDataClauseSimple : public SearchDataClause {
|
||||||
public:
|
public:
|
||||||
SearchDataClauseSimple(SClType tp, const std::string& txt,
|
SearchDataClauseSimple(SClType tp, const std::string& txt,
|
||||||
const std::string& fld = std::string())
|
const std::string& fld = std::string())
|
||||||
: SearchDataClause(tp), m_text(txt), m_field(fld)
|
: SearchDataClause(tp), m_text(txt), m_field(fld), m_curcl(0)
|
||||||
{
|
{
|
||||||
m_haveWildCards =
|
m_haveWildCards =
|
||||||
(txt.find_first_of(cstr_minwilds) != std::string::npos);
|
(txt.find_first_of(cstr_minwilds) != std::string::npos);
|
||||||
|
@ -345,9 +339,10 @@ protected:
|
||||||
std::string m_text; // Raw user entry text.
|
std::string m_text; // Raw user entry text.
|
||||||
std::string m_field; // Field specification if any
|
std::string m_field; // Field specification if any
|
||||||
HighlightData m_hldata;
|
HighlightData m_hldata;
|
||||||
|
// Current count of Xapian clauses, to check against expansion limit
|
||||||
int m_curcl;
|
int m_curcl;
|
||||||
|
|
||||||
bool processUserString(Rcl::Db &db, const string &iq, int mods,
|
bool processUserString(Rcl::Db &db, const string &iq,
|
||||||
std::string &ermsg,
|
std::string &ermsg,
|
||||||
void* pq, int slack = 0, bool useNear = false);
|
void* pq, int slack = 0, bool useNear = false);
|
||||||
bool expandTerm(Rcl::Db &db, std::string& ermsg, int mods,
|
bool expandTerm(Rcl::Db &db, std::string& ermsg, int mods,
|
||||||
|
|
|
@ -43,11 +43,18 @@ namespace Rcl {
|
||||||
/**
|
/**
|
||||||
* Expand for one or several languages
|
* Expand for one or several languages
|
||||||
*/
|
*/
|
||||||
bool StemDb::stemExpand(const std::string& langs, const std::string& term,
|
bool StemDb::stemExpand(const std::string& langs, const std::string& _term,
|
||||||
vector<string>& result)
|
vector<string>& result)
|
||||||
{
|
{
|
||||||
vector<string> llangs;
|
vector<string> llangs;
|
||||||
stringToStrings(langs, llangs);
|
stringToStrings(langs, llangs);
|
||||||
|
|
||||||
|
// The stemdb keys may have kept their diacritics or not but they
|
||||||
|
// are always lower-case. It would be more logical for the term
|
||||||
|
// transformers to perform before doing the stemming, but this
|
||||||
|
// would be inefficient when there are several stemming languages
|
||||||
|
string term;
|
||||||
|
unacmaybefold(_term, term, "UTF-8", UNACOP_FOLD);
|
||||||
|
|
||||||
for (vector<string>::const_iterator it = llangs.begin();
|
for (vector<string>::const_iterator it = llangs.begin();
|
||||||
it != llangs.end(); it++) {
|
it != llangs.end(); it++) {
|
||||||
|
|
|
@ -210,6 +210,7 @@ private:
|
||||||
// Lowercase accented stem to expansion. Family member name: language
|
// Lowercase accented stem to expansion. Family member name: language
|
||||||
static const std::string synFamStem("Stm");
|
static const std::string synFamStem("Stm");
|
||||||
|
|
||||||
|
#ifndef RCL_INDEX_STRIPCHARS
|
||||||
// Lowercase unaccented stem to expansion. Family member name: language
|
// Lowercase unaccented stem to expansion. Family member name: language
|
||||||
static const std::string synFamStemUnac("StU");
|
static const std::string synFamStemUnac("StU");
|
||||||
|
|
||||||
|
@ -217,6 +218,7 @@ static const std::string synFamStemUnac("StU");
|
||||||
// member, named "all". This set is used for separate case/diac
|
// member, named "all". This set is used for separate case/diac
|
||||||
// expansion by post-filtering the results of dual expansion.
|
// expansion by post-filtering the results of dual expansion.
|
||||||
static const std::string synFamDiCa("DCa");
|
static const std::string synFamDiCa("DCa");
|
||||||
|
#endif // !RCL_INDEX_STRIPCHARS
|
||||||
|
|
||||||
} // end namespace Rcl
|
} // end namespace Rcl
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue