|
a/src/rcldb/rclquery.cpp |
|
b/src/rcldb/rclquery.cpp |
|
... |
|
... |
18 |
#include <stdlib.h>
|
18 |
#include <stdlib.h>
|
19 |
#include <string.h>
|
19 |
#include <string.h>
|
20 |
#include <stdio.h>
|
20 |
#include <stdio.h>
|
21 |
|
21 |
|
22 |
#include <vector>
|
22 |
#include <vector>
|
|
|
23 |
#include <sstream>
|
|
|
24 |
using namespace std;
|
23 |
|
25 |
|
24 |
#include "xapian.h"
|
26 |
#include "xapian.h"
|
25 |
|
27 |
|
26 |
#include "cstr.h"
|
28 |
#include "cstr.h"
|
27 |
#include "rclconfig.h"
|
29 |
#include "rclconfig.h"
|
|
... |
|
... |
33 |
#include "conftree.h"
|
35 |
#include "conftree.h"
|
34 |
#include "smallut.h"
|
36 |
#include "smallut.h"
|
35 |
#include "searchdata.h"
|
37 |
#include "searchdata.h"
|
36 |
#include "unacpp.h"
|
38 |
#include "unacpp.h"
|
37 |
|
39 |
|
38 |
#ifndef NO_NAMESPACES
|
|
|
39 |
namespace Rcl {
|
40 |
namespace Rcl {
|
40 |
#endif
|
41 |
// This is used as a marker inside the abstract frag lists, but
|
41 |
|
42 |
// normally doesn't remain in final output (which is built with a
|
|
|
43 |
// custom sep. by our caller).
|
|
|
44 |
static const string cstr_ellipsis("...");
|
42 |
|
45 |
|
43 |
// Field names inside the index data record may differ from the rcldoc ones
|
46 |
// Field names inside the index data record may differ from the rcldoc ones
|
44 |
// (esp.: caption / title)
|
47 |
// (esp.: caption / title)
|
45 |
static const string& docfToDatf(const string& df)
|
48 |
static const string& docfToDatf(const string& df)
|
46 |
{
|
49 |
{
|
|
... |
|
... |
292 |
}
|
295 |
}
|
293 |
|
296 |
|
294 |
return true;
|
297 |
return true;
|
295 |
}
|
298 |
}
|
296 |
|
299 |
|
|
|
300 |
abstract_result Query::makeDocAbstract(Doc &doc,
|
|
|
301 |
vector<pair<int, string> >& abstract,
|
|
|
302 |
int maxoccs, int ctxwords)
|
|
|
303 |
{
|
|
|
304 |
LOGDEB(("makeDocAbstract: maxoccs %d ctxwords %d\n", maxoccs, ctxwords));
|
|
|
305 |
if (!m_db || !m_db->m_ndb || !m_db->m_ndb->m_isopen || !m_nq) {
|
|
|
306 |
LOGERR(("Query::makeDocAbstract: no db or no nq\n"));
|
|
|
307 |
return ABSRES_ERROR;
|
|
|
308 |
}
|
|
|
309 |
abstract_result ret = ABSRES_ERROR;
|
|
|
310 |
XAPTRY(ret = m_nq->makeAbstract(doc.xdocid, abstract, maxoccs, ctxwords),
|
|
|
311 |
m_db->m_ndb->xrdb, m_reason);
|
|
|
312 |
if (!m_reason.empty())
|
|
|
313 |
return ABSRES_ERROR;
|
|
|
314 |
return ret;
|
|
|
315 |
}
|
|
|
316 |
|
|
|
317 |
bool Query::makeDocAbstract(Doc &doc, vector<string>& abstract)
|
|
|
318 |
{
|
|
|
319 |
vector<pair<int, string> > vpabs;
|
|
|
320 |
if (!makeDocAbstract(doc, vpabs))
|
|
|
321 |
return false;
|
|
|
322 |
for (vector<pair<int, string> >::const_iterator it = vpabs.begin();
|
|
|
323 |
it != vpabs.end(); it++) {
|
|
|
324 |
string chunk;
|
|
|
325 |
if (it->first > 0) {
|
|
|
326 |
ostringstream ss;
|
|
|
327 |
ss << it->first;
|
|
|
328 |
chunk += string(" [p ") + ss.str() + "] ";
|
|
|
329 |
}
|
|
|
330 |
chunk += it->second;
|
|
|
331 |
abstract.push_back(chunk);
|
|
|
332 |
}
|
|
|
333 |
return true;
|
|
|
334 |
}
|
|
|
335 |
|
|
|
336 |
bool Query::makeDocAbstract(Doc &doc, string& abstract)
|
|
|
337 |
{
|
|
|
338 |
vector<pair<int, string> > vpabs;
|
|
|
339 |
if (!makeDocAbstract(doc, vpabs))
|
|
|
340 |
return false;
|
|
|
341 |
for (vector<pair<int, string> >::const_iterator it = vpabs.begin();
|
|
|
342 |
it != vpabs.end(); it++) {
|
|
|
343 |
abstract.append(it->second);
|
|
|
344 |
abstract.append(cstr_ellipsis);
|
|
|
345 |
}
|
|
|
346 |
return m_reason.empty() ? true : false;
|
|
|
347 |
}
|
|
|
348 |
|
|
|
349 |
int Query::getFirstMatchPage(Doc &doc)
|
|
|
350 |
{
|
|
|
351 |
LOGDEB1(("Db::getFirstMatchPages\n"));;
|
|
|
352 |
if (!m_nq) {
|
|
|
353 |
LOGERR(("Query::getFirstMatchPage: no nq\n"));
|
|
|
354 |
return false;
|
|
|
355 |
}
|
|
|
356 |
int pagenum = -1;
|
|
|
357 |
XAPTRY(pagenum = m_nq->getFirstMatchPage(Xapian::docid(doc.xdocid)),
|
|
|
358 |
m_db->m_ndb->xrdb, m_reason);
|
|
|
359 |
return m_reason.empty() ? pagenum : -1;
|
|
|
360 |
}
|
|
|
361 |
|
297 |
|
362 |
|
298 |
// Mset size
|
363 |
// Mset size
|
299 |
static const int qquantum = 50;
|
364 |
static const int qquantum = 50;
|
300 |
|
365 |
|
301 |
// Get estimated result count for query. Xapian actually does most of
|
366 |
// Get estimated result count for query. Xapian actually does most of
|