do not include excluded terms in the highlight information data

This commit is contained in:
Jean-Francois Dockes 2019-07-17 11:35:03 +02:00
parent e1b98c1e22
commit 83da93cab9

View File

@ -493,7 +493,7 @@ bool SearchDataClauseSimple::expandTerm(Rcl::Db &db,
} }
if (noexpansion) { if (!m_exclude && noexpansion) {
oexp.push_back(prefix + term); oexp.push_back(prefix + term);
m_hldata.terms[term] = term; m_hldata.terms[term] = term;
LOGDEB("ExpandTerm: noexpansion: final: "<<stringsToString(oexp)<< "\n"); LOGDEB("ExpandTerm: noexpansion: final: "<<stringsToString(oexp)<< "\n");
@ -533,9 +533,11 @@ bool SearchDataClauseSimple::expandTerm(Rcl::Db &db,
oexp.push_back(prefix + term); oexp.push_back(prefix + term);
// Remember the uterm-to-expansion links // Remember the uterm-to-expansion links
if (!m_exclude) {
for (const auto& entry : oexp) { for (const auto& entry : oexp) {
m_hldata.terms[strip_prefix(entry)] = term; m_hldata.terms[strip_prefix(entry)] = term;
} }
}
LOGDEB("ExpandTerm: final: " << stringsToString(oexp) << "\n"); LOGDEB("ExpandTerm: final: " << stringsToString(oexp) << "\n");
return true; return true;
} }
@ -569,12 +571,14 @@ void SearchDataClauseSimple::processSimpleSpan(
return; return;
// Set up the highlight data. No prefix should go in there // Set up the highlight data. No prefix should go in there
if (!m_exclude) {
for (const auto& term : exp) { for (const auto& term : exp) {
HighlightData::TermGroup tg; HighlightData::TermGroup tg;
tg.term = term.substr(prefix.size()); tg.term = term.substr(prefix.size());
tg.grpsugidx = m_hldata.ugroups.size() - 1; tg.grpsugidx = m_hldata.ugroups.size() - 1;
m_hldata.index_term_groups.push_back(tg); m_hldata.index_term_groups.push_back(tg);
} }
}
// Push either term or OR of stem-expanded set // Push either term or OR of stem-expanded set
Xapian::Query xq(Xapian::Query::OP_OR, exp.begin(), exp.end()); Xapian::Query xq(Xapian::Query::OP_OR, exp.begin(), exp.end());
@ -703,6 +707,7 @@ void SearchDataClauseSimple::processPhraseOrNear(Rcl::Db &db, string& ermsg,
// Insert the search groups and slacks in the highlight data, with // Insert the search groups and slacks in the highlight data, with
// a reference to the user entry that generated them: // a reference to the user entry that generated them:
if (!m_exclude) {
HighlightData::TermGroup tg; HighlightData::TermGroup tg;
tg.orgroups = groups; tg.orgroups = groups;
tg.slack = slack; tg.slack = slack;
@ -711,6 +716,7 @@ void SearchDataClauseSimple::processPhraseOrNear(Rcl::Db &db, string& ermsg,
HighlightData::TermGroup::TGK_PHRASE : HighlightData::TermGroup::TGK_PHRASE :
HighlightData::TermGroup::TGK_NEAR; HighlightData::TermGroup::TGK_NEAR;
m_hldata.index_term_groups.push_back(tg); m_hldata.index_term_groups.push_back(tg);
}
} }
// Trim string beginning with ^ or ending with $ and convert to flags // Trim string beginning with ^ or ending with $ and convert to flags
@ -828,13 +834,17 @@ bool SearchDataClauseSimple::processUserString(Rcl::Db &db, const string &iq,
int lmods = mods; int lmods = mods;
if (tpq.nostemexps().front()) if (tpq.nostemexps().front())
lmods |= SearchDataClause::SDCM_NOSTEMMING; lmods |= SearchDataClause::SDCM_NOSTEMMING;
if (!m_exclude) {
m_hldata.ugroups.push_back(tpq.terms()); m_hldata.ugroups.push_back(tpq.terms());
}
processSimpleSpan(db, ermsg, tpq.terms().front(), processSimpleSpan(db, ermsg, tpq.terms().front(),
lmods, &pqueries); lmods, &pqueries);
} }
break; break;
default: default:
if (!m_exclude) {
m_hldata.ugroups.push_back(tpq.terms()); m_hldata.ugroups.push_back(tpq.terms());
}
processPhraseOrNear(db, ermsg, &tpq, mods, &pqueries, processPhraseOrNear(db, ermsg, &tpq, mods, &pqueries,
useNear, slack); useNear, slack);
} }