const string cleanup
This commit is contained in:
+4
-5
@@ -94,7 +94,6 @@ static const string cstr_syntAbs("?!#@");
|
||||
// Only ONE field name inside the index data record differs from the
|
||||
// Rcl::Doc ones: caption<->title, for a remnant of compatibility with
|
||||
// omega
|
||||
static const string cstr_keycap("caption");
|
||||
|
||||
// Static/Default table for field->prefix/weight translation.
|
||||
// This is logically const after initialization. Can't use a
|
||||
@@ -125,7 +124,7 @@ static void initFldToTraits()
|
||||
fldToTraits["ext"] = FieldTraits("XE");
|
||||
fldToTraits[Doc::keyfn] = FieldTraits("XSFN");
|
||||
|
||||
fldToTraits[cstr_keycap] = FieldTraits("S");
|
||||
fldToTraits[cstr_caption] = FieldTraits("S");
|
||||
fldToTraits[Doc::keytt] = FieldTraits("S");
|
||||
fldToTraits["subject"] = FieldTraits("S");
|
||||
|
||||
@@ -198,7 +197,7 @@ bool Db::Native::dbDataToRclDoc(Xapian::docid docid, std::string &data,
|
||||
parms.get(Doc::keyfmt, doc.fmtime);
|
||||
parms.get(Doc::keydmt, doc.dmtime);
|
||||
parms.get(Doc::keyoc, doc.origcharset);
|
||||
parms.get(cstr_keycap, doc.meta[Doc::keytt]);
|
||||
parms.get(cstr_caption, doc.meta[Doc::keytt]);
|
||||
parms.get(Doc::keykw, doc.meta[Doc::keykw]);
|
||||
parms.get(Doc::keyabs, doc.meta[Doc::keyabs]);
|
||||
// Possibly remove synthetic abstract indicator (if it's there, we
|
||||
@@ -1179,7 +1178,7 @@ bool Db::addOrUpdate(const string &udi, const string &parent_udi,
|
||||
doc.meta[Doc::keytt] =
|
||||
neutchars(truncate_to_word(doc.meta[Doc::keytt], 150), cstr_nc);
|
||||
if (!doc.meta[Doc::keytt].empty())
|
||||
RECORD_APPEND(record, cstr_keycap, doc.meta[Doc::keytt]);
|
||||
RECORD_APPEND(record, cstr_caption, doc.meta[Doc::keytt]);
|
||||
|
||||
trimstring(doc.meta[Doc::keykw], " \t\r\n");
|
||||
doc.meta[Doc::keykw] =
|
||||
@@ -1526,7 +1525,7 @@ bool Db::filenameWildExp(const string& fnexp, list<string>& names)
|
||||
// each end: match any substring
|
||||
if (pattern[0] == '"' && pattern[pattern.size()-1] == '"') {
|
||||
pattern = pattern.substr(1, pattern.size() -2);
|
||||
} else if (pattern.find_first_of("*?[") == string::npos &&
|
||||
} else if (pattern.find_first_of(cstr_minwilds) == string::npos &&
|
||||
!unaciscapital(pattern)) {
|
||||
pattern = "*" + pattern + "*";
|
||||
} // else let it be
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
#include "cstr.h"
|
||||
#include "refcntr.h"
|
||||
#include "rcldoc.h"
|
||||
#include "stoplist.h"
|
||||
@@ -186,7 +187,7 @@ class Db {
|
||||
enum MatchType {ET_WILD, ET_REGEXP, ET_STEM};
|
||||
bool termMatch(MatchType typ, const string &lang, const string &s,
|
||||
TermMatchResult& result, int max = -1,
|
||||
const string& field = "",
|
||||
const string& field = cstr_null,
|
||||
string *prefix = 0
|
||||
);
|
||||
/** Return min and max years for doc mod times in db */
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "xapian.h"
|
||||
|
||||
#include "cstr.h"
|
||||
#include "rcldb.h"
|
||||
#include "rcldb_p.h"
|
||||
#include "rclquery.h"
|
||||
@@ -39,17 +40,15 @@
|
||||
namespace Rcl {
|
||||
#endif
|
||||
|
||||
static const string cstr_keycap("caption");
|
||||
static const string cstr_keydmtime("dmtime");
|
||||
|
||||
// Field names inside the index data record may differ from the rcldoc ones
|
||||
// (esp.: caption / title)
|
||||
static const string& docfToDatf(const string& df)
|
||||
{
|
||||
if (!df.compare(Doc::keytt)) {
|
||||
return cstr_keycap;
|
||||
return cstr_caption;
|
||||
} else if (!df.compare(Doc::keymt)) {
|
||||
return cstr_keydmtime;
|
||||
return cstr_dmtime;
|
||||
} else {
|
||||
return df;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include "xapian.h"
|
||||
|
||||
#include "cstr.h"
|
||||
#include "rcldb.h"
|
||||
#include "searchdata.h"
|
||||
#include "debuglog.h"
|
||||
@@ -346,8 +347,10 @@ bool SearchData::maybeAddAutoPhrase()
|
||||
words += clp->gettext();
|
||||
}
|
||||
|
||||
if (words.find_first_of("\"*[]?") != string::npos && // has wildcards
|
||||
TextSplit::countWords(words) <= 1) { // Just one word.
|
||||
// If there are wildcards or quotes in there, or this is a single word,
|
||||
// bail out
|
||||
if (words.find_first_of("\"*[?") != string::npos &&
|
||||
TextSplit::countWords(words) <= 1) {
|
||||
LOGDEB2(("SearchData::maybeAddAutoPhrase: wildcards or single word\n"));
|
||||
return false;
|
||||
}
|
||||
@@ -561,7 +564,7 @@ void StringToXapianQ::expandTerm(bool nostemexp,
|
||||
return;
|
||||
}
|
||||
|
||||
bool haswild = term.find_first_of("*?[") != string::npos;
|
||||
bool haswild = term.find_first_of(cstr_minwilds) != string::npos;
|
||||
|
||||
// No stemming if there are wildcards or prevented globally.
|
||||
if (haswild || m_stemlang.empty())
|
||||
@@ -857,8 +860,6 @@ bool StringToXapianQ::processUserString(const string &iq,
|
||||
return true;
|
||||
}
|
||||
|
||||
static const string cstr_null;
|
||||
|
||||
// Translate a simple OR, AND, or EXCL search clause.
|
||||
bool SearchDataClauseSimple::toNativeQuery(Rcl::Db &db, void *p,
|
||||
const string& stemlang)
|
||||
@@ -964,10 +965,10 @@ bool SearchDataClauseDist::toNativeQuery(Rcl::Db &db, void *p,
|
||||
// stringToXapianQueries() to lowercase and simplify the phrase
|
||||
// terms etc. This will result into a single (complex)
|
||||
// Xapian::Query.
|
||||
if (m_text.find_first_of("\"") != string::npos) {
|
||||
if (m_text.find('\"') != string::npos) {
|
||||
m_text = neutchars(m_text, "\"");
|
||||
}
|
||||
string s = string("\"") + m_text + string("\"");
|
||||
string s = cstr_dquote + m_text + cstr_dquote;
|
||||
bool useNear = (m_tp == SCLT_NEAR);
|
||||
StringToXapianQ tr(db, m_field, l_stemlang, doBoostUserTerm);
|
||||
if (!tr.processUserString(s, m_reason, pqueries, db.getStopList(),
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "rcldb.h"
|
||||
#include "refcntr.h"
|
||||
#include "smallut.h"
|
||||
#include "cstr.h"
|
||||
|
||||
class RclConfig;
|
||||
|
||||
@@ -215,7 +216,7 @@ public:
|
||||
SearchDataClauseSimple(SClType tp, const string& txt,
|
||||
const string& fld = string())
|
||||
: SearchDataClause(tp), m_text(txt), m_field(fld), m_slack(0) {
|
||||
m_haveWildCards = (txt.find_first_of("*?[") != string::npos);
|
||||
m_haveWildCards = (txt.find_first_of(cstr_minwilds) != string::npos);
|
||||
}
|
||||
|
||||
virtual ~SearchDataClauseSimple() {}
|
||||
|
||||
@@ -291,13 +291,14 @@ static bool stemExpandOne(const std::string& dbdir,
|
||||
// Build expansion list from database data No need for
|
||||
// a conftree, but we need to massage the data a
|
||||
// little
|
||||
string::size_type pos = data.find_first_of("=");
|
||||
++pos;
|
||||
string::size_type pos1 = data.find_last_of("\n");
|
||||
string::size_type pos = data.find('=');
|
||||
string::size_type pos1 = data.rfind('\n');
|
||||
if (pos == string::npos || pos1 == string::npos ||
|
||||
pos1 <= pos) {
|
||||
// ??
|
||||
pos1 <= pos+1) {
|
||||
LOGERR(("stemExpand: bad data in db: [%s]\n",
|
||||
data.c_str()));
|
||||
} else {
|
||||
++pos;
|
||||
stringToStrings(data.substr(pos, pos1-pos), result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user