dont generate error for empty abstract this is a problem for python

This commit is contained in:
Jean-Francois Dockes 2012-10-21 17:57:08 +02:00
parent de5763f663
commit 5f0e348216
2 changed files with 11 additions and 8 deletions

View File

@ -290,8 +290,8 @@ abstract_result Query::Native::makeAbstract(Xapian::docid docid,
int imaxoccs, int ictxwords) int imaxoccs, int ictxwords)
{ {
Chrono chron; Chrono chron;
LOGDEB2(("makeAbstract:%d: maxlen %d wWidth %d imaxoccs %d\n", chron.ms(), LOGABS(("makeAbstract: docid %l imaxoccs %d ictxwords %d\n",
m_rcldb->m_synthAbsLen, m_rcldb->m_synthAbsWordCtxLen, imaxoccs)); long(docid), imaxoccs, ictxwords));
// The (unprefixed) terms matched by this document // The (unprefixed) terms matched by this document
vector<string> matchedTerms; vector<string> matchedTerms;
@ -464,15 +464,15 @@ abstract_result Query::Native::makeAbstract(Xapian::docid docid,
} }
} }
} }
LOGABS(("makeAbstract:%d:chosen number of positions %d\n",
chron.millis(), totaloccs));
maxpos += ctxwords + 1; maxpos += ctxwords + 1;
LOGABS(("makeAbstract:%d:chosen number of positions %d\n",
chron.millis(), totaloccs));
// This can happen if there are term occurences in the keywords // This can happen if there are term occurences in the keywords
// etc. but not elsewhere ? // etc. but not elsewhere ?
if (totaloccs == 0) { if (totaloccs == 0) {
LOGDEB1(("makeAbstract: no occurrences\n")); LOGDEB(("makeAbstract: no occurrences\n"));
return ABSRES_ERROR; return ABSRES_OK;
} }
// Walk all document's terms position lists and populate slots // Walk all document's terms position lists and populate slots

View File

@ -318,8 +318,11 @@ abstract_result Query::makeDocAbstract(Doc &doc,
abstract_result ret = ABSRES_ERROR; abstract_result ret = ABSRES_ERROR;
XAPTRY(ret = m_nq->makeAbstract(doc.xdocid, abstract, maxoccs, ctxwords), XAPTRY(ret = m_nq->makeAbstract(doc.xdocid, abstract, maxoccs, ctxwords),
m_db->m_ndb->xrdb, m_reason); m_db->m_ndb->xrdb, m_reason);
if (!m_reason.empty()) if (!m_reason.empty()) {
LOGDEB(("makeDocAbstract: makeAbstract error, reason: %s\n",
m_reason.c_str()));
return ABSRES_ERROR; return ABSRES_ERROR;
}
return ret; return ret;
} }