allow disabling storing an abstract made of the beginning of document by setting its length parameter to 0

This commit is contained in:
Jean-Francois Dockes 2017-02-27 18:26:34 +01:00
parent c8cc64366d
commit 2cfb4f7e4c

View File

@ -1216,7 +1216,7 @@ string Db::getSpellingSuggestion(const string& word)
void Db::setAbstractParams(int idxtrunc, int syntlen, int syntctxlen) void Db::setAbstractParams(int idxtrunc, int syntlen, int syntctxlen)
{ {
LOGDEB1("Db::setAbstractParams: trunc " << (idxtrunc) << " syntlen " << (syntlen) << " ctxlen " << (syntctxlen) << "\n" ); LOGDEB1("Db::setAbstractParams: trunc " << (idxtrunc) << " syntlen " << (syntlen) << " ctxlen " << (syntctxlen) << "\n" );
if (idxtrunc > 0) if (idxtrunc >= 0)
m_idxAbsTruncLen = idxtrunc; m_idxAbsTruncLen = idxtrunc;
if (syntlen > 0) if (syntlen > 0)
m_synthAbsLen = syntlen; m_synthAbsLen = syntlen;
@ -1494,24 +1494,26 @@ bool Db::addOrUpdate(const string &udi, const string &parent_udi, Doc &doc)
// original file. // original file.
// Note that the map accesses by operator[] create empty entries if they // Note that the map accesses by operator[] create empty entries if they
// don't exist yet. // don't exist yet.
string& absref = doc.meta[Doc::keyabs]; if (m_idxAbsTruncLen > 0) {
trimstring(absref, " \t\r\n"); string& absref = doc.meta[Doc::keyabs];
if (absref.empty()) { trimstring(absref, " \t\r\n");
if (!doc.text.empty()) if (absref.empty()) {
absref = cstr_syntAbs + if (!doc.text.empty())
neutchars(truncate_to_word(doc.text, m_idxAbsTruncLen), absref = cstr_syntAbs +
cstr_nc); neutchars(truncate_to_word(doc.text, m_idxAbsTruncLen),
} else { cstr_nc);
absref = neutchars(truncate_to_word(absref, m_idxAbsTruncLen), } else {
cstr_nc); absref = neutchars(truncate_to_word(absref, m_idxAbsTruncLen),
} cstr_nc);
// Do the append here to avoid the different truncation done }
// in the regular "stored" loop // Do the append here to avoid the different truncation done
if (!absref.empty()) { // in the regular "stored" loop
RECORD_APPEND(record, Doc::keyabs, absref); if (!absref.empty()) {
absref.clear(); RECORD_APPEND(record, Doc::keyabs, absref);
absref.clear();
}
} }
// Append all regular "stored" meta fields // Append all regular "stored" meta fields
const set<string>& stored = m_config->getStoredFields(); const set<string>& stored = m_config->getStoredFields();
for (set<string>::const_iterator it = stored.begin(); for (set<string>::const_iterator it = stored.begin();