--- a/src/rcldb/rcldb.cpp
+++ b/src/rcldb/rcldb.cpp
@@ -1060,8 +1060,7 @@
Xapian::termpos curpos;
TextSplitDb(Xapian::Document &d, TermProc *prc)
- : TextSplitP(prc),
- doc(d), basepos(1), curpos(0), wdfinc(1)
+ : TextSplitP(prc), doc(d), basepos(1), curpos(0)
{}
// Reimplement text_to_words to insert the begin and end anchor terms.
@@ -1072,7 +1071,7 @@
try {
// Index the possibly prefixed start term.
- doc.add_posting(prefix + start_of_field_term, basepos, wdfinc);
+ doc.add_posting(ft.pfx + start_of_field_term, basepos, ft.wdfinc);
++basepos;
} XCATCHERROR(ermsg);
if (!ermsg.empty()) {
@@ -1087,8 +1086,8 @@
try {
// Index the possibly prefixed end term.
- doc.add_posting(prefix + end_of_field_term, basepos + curpos + 1,
- wdfinc);
+ doc.add_posting(ft.pfx + end_of_field_term, basepos + curpos + 1,
+ ft.wdfinc);
++basepos;
} XCATCHERROR(ermsg);
if (!ermsg.empty()) {
@@ -1103,27 +1102,15 @@
return true;
}
- void setprefix(const string& pref)
+ void setTraits(const FieldTraits& ftp)
{
- if (pref.empty())
- prefix.clear();
- else
- prefix = wrap_prefix(pref);
- }
-
- void setwdfinc(int i)
- {
- wdfinc = i;
+ ft = ftp;
}
friend class TermProcIdx;
private:
- // If prefix is set, we also add a posting for the prefixed terms
- // (ie: for titles, add postings for both "term" and "Sterm")
- string prefix;
- // Some fields have more weight
- int wdfinc;
+ FieldTraits ft;
};
class TermProcIdx : public TermProc {
@@ -1145,15 +1132,18 @@
try {
// Index without prefix, using the field-specific weighting
LOGDEB1(("Emitting term at %d : [%s]\n", pos, term.c_str()));
- m_ts->doc.add_posting(term, pos, m_ts->wdfinc);
+ if (!m_ts->ft.pfxonly)
+ m_ts->doc.add_posting(term, pos, m_ts->ft.wdfinc);
+
#ifdef TESTING_XAPIAN_SPELL
if (Db::isSpellingCandidate(term)) {
m_ts->db.add_spelling(term);
}
#endif
// Index the prefixed term.
- if (!m_ts->prefix.empty()) {
- m_ts->doc.add_posting(m_ts->prefix + term, pos, m_ts->wdfinc);
+ if (!m_ts->ft.pfx.empty()) {
+ m_ts->doc.add_posting(m_ts->ft.pfx + term, pos,
+ m_ts->ft.wdfinc);
}
return true;
} XCATCHERROR(ermsg);
@@ -1168,7 +1158,7 @@
return;
}
- m_ts->doc.add_posting(m_ts->prefix + page_break_term, pos);
+ m_ts->doc.add_posting(m_ts->ft.pfx + page_break_term, pos);
if (pos == m_lastpagepos) {
m_pageincr++;
LOGDEB2(("newpage: same pos, pageincr %d lastpagepos %d\n",
@@ -1351,15 +1341,15 @@
LOGDEB0(("Db::add: field [%s] pfx [%s] inc %d: [%s]\n",
meta_it->first.c_str(), ftp->pfx.c_str(), ftp->wdfinc,
meta_it->second.c_str()));
- splitter.setprefix(ftp->pfx);
- splitter.setwdfinc(ftp->wdfinc);
+ splitter.setTraits(*ftp);
if (!splitter.text_to_words(meta_it->second))
LOGDEB(("Db::addOrUpdate: split failed for %s\n",
meta_it->first.c_str()));
}
}
- splitter.setprefix(string());
- splitter.setwdfinc(1);
+
+ // Reset to no prefix and default params
+ splitter.setTraits(FieldTraits());
if (splitter.curpos < baseTextPosition)
splitter.basepos = baseTextPosition;
@@ -1634,8 +1624,7 @@
LOGDEB0(("Db::xattrOnly: field [%s] pfx [%s] inc %d: [%s]\n",
meta_it->first.c_str(), ftp->pfx.c_str(), ftp->wdfinc,
meta_it->second.c_str()));
- splitter->setprefix(ftp->pfx);
- splitter->setwdfinc(ftp->wdfinc);
+ splitter->setTraits(*ftp);
if (!splitter->text_to_words(meta_it->second))
LOGDEB(("Db::xattrOnly: split failed for %s\n",
meta_it->first.c_str()));