|
a/src/query/recollq.cpp |
|
b/src/query/recollq.cpp |
1 |
#ifndef lint
|
1 |
#ifndef lint
|
2 |
static char rcsid[] = "@(#$Id: recollq.cpp,v 1.12 2007-12-13 06:58:21 dockes Exp $ (C) 2006 J.F.Dockes";
|
2 |
static char rcsid[] = "@(#$Id: recollq.cpp,v 1.13 2008-06-13 18:22:46 dockes Exp $ (C) 2006 J.F.Dockes";
|
3 |
#endif
|
3 |
#endif
|
4 |
/*
|
4 |
/*
|
5 |
* This program is free software; you can redistribute it and/or modify
|
5 |
* This program is free software; you can redistribute it and/or modify
|
6 |
* it under the terms of the GNU General Public License as published by
|
6 |
* it under the terms of the GNU General Public License as published by
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
|
... |
|
... |
30 |
|
30 |
|
31 |
#include <iostream>
|
31 |
#include <iostream>
|
32 |
using namespace std;
|
32 |
using namespace std;
|
33 |
|
33 |
|
34 |
#include "rcldb.h"
|
34 |
#include "rcldb.h"
|
|
|
35 |
#include "rclquery.h"
|
35 |
#include "rclconfig.h"
|
36 |
#include "rclconfig.h"
|
36 |
#include "pathut.h"
|
37 |
#include "pathut.h"
|
37 |
#include "rclinit.h"
|
38 |
#include "rclinit.h"
|
38 |
#include "debuglog.h"
|
39 |
#include "debuglog.h"
|
39 |
#include "wasastringtoquery.h"
|
40 |
#include "wasastringtoquery.h"
|
|
... |
|
... |
130 |
if (!rclconfig || !rclconfig->ok()) {
|
131 |
if (!rclconfig || !rclconfig->ok()) {
|
131 |
fprintf(stderr, "Recoll init failed: %s\n", reason.c_str());
|
132 |
fprintf(stderr, "Recoll init failed: %s\n", reason.c_str());
|
132 |
exit(1);
|
133 |
exit(1);
|
133 |
}
|
134 |
}
|
134 |
dbdir = rclconfig->getDbDir();
|
135 |
dbdir = rclconfig->getDbDir();
|
135 |
rcldb.open(dbdir, rclconfig->getStopfile(),
|
136 |
rcldb.open(dbdir, rclconfig->getStopfile(), Rcl::Db::DbRO);
|
136 |
Rcl::Db::DbRO, Rcl::Db::QO_STEM);
|
|
|
137 |
|
137 |
|
138 |
Rcl::SearchData *sd = 0;
|
138 |
Rcl::SearchData *sd = 0;
|
139 |
|
139 |
|
140 |
if (op_flags & (OPT_a|OPT_o|OPT_f)) {
|
140 |
if (op_flags & (OPT_a|OPT_o|OPT_f)) {
|
141 |
sd = new Rcl::SearchData(Rcl::SCLT_OR);
|
141 |
sd = new Rcl::SearchData(Rcl::SCLT_OR);
|
|
... |
|
... |
164 |
cerr << "Query string interpretation failed: " << reason << endl;
|
164 |
cerr << "Query string interpretation failed: " << reason << endl;
|
165 |
return 1;
|
165 |
return 1;
|
166 |
}
|
166 |
}
|
167 |
|
167 |
|
168 |
RefCntr<Rcl::SearchData> rq(sd);
|
168 |
RefCntr<Rcl::SearchData> rq(sd);
|
|
|
169 |
Rcl::Query query(&rcldb);
|
169 |
rcldb.setQuery(rq, Rcl::Db::QO_STEM);
|
170 |
query.setQuery(rq, Rcl::Query::QO_STEM);
|
170 |
int cnt = rcldb.getResCnt();
|
171 |
int cnt = query.getResCnt();
|
171 |
if (!(op_flags & OPT_b)) {
|
172 |
if (!(op_flags & OPT_b)) {
|
172 |
cout << "Recoll query: " << rq->getDescription() << endl;
|
173 |
cout << "Recoll query: " << rq->getDescription() << endl;
|
173 |
if (cnt <= limit)
|
174 |
if (cnt <= limit)
|
174 |
cout << cnt << " results" << endl;
|
175 |
cout << cnt << " results" << endl;
|
175 |
else
|
176 |
else
|
|
... |
|
... |
178 |
|
179 |
|
179 |
string tmpdir;
|
180 |
string tmpdir;
|
180 |
for (int i = 0; i < limit; i++) {
|
181 |
for (int i = 0; i < limit; i++) {
|
181 |
int pc;
|
182 |
int pc;
|
182 |
Rcl::Doc doc;
|
183 |
Rcl::Doc doc;
|
183 |
if (!rcldb.getDoc(i, doc, &pc))
|
184 |
if (!query.getDoc(i, doc, &pc))
|
184 |
break;
|
185 |
break;
|
185 |
|
186 |
|
186 |
if (op_flags & OPT_b) {
|
187 |
if (op_flags & OPT_b) {
|
187 |
cout << doc.url.c_str() << endl;
|
188 |
cout << doc.url.c_str() << endl;
|
188 |
} else {
|
189 |
} else {
|