80
80
static char *thisprog;
81
81
static char usage [] =
82
" -P: Show date span for documents in index\n"
83
" [-o|-a|-f] <query string>\n"
82
" -P: Show the date span for all the documents present in the index\n"
83
" [-o|-a|-f] [-q] <query string>\n"
84
84
" Runs a recoll query and displays result lines. \n"
85
85
" Default: will interpret the argument(s) as a xesam query string\n"
86
86
" query may be like: \n"
87
87
" implicit AND, Exclusion, field spec: t1 -t2 title:t3\n"
88
88
" OR has priority: t1 OR t2 t3 OR t4 means (t1 OR t2) AND (t3 OR t4)\n"
89
89
" Phrase: \"t1 t2\" (needs additional quoting on cmd line)\n"
90
" -o Emulate the gui simple search in ANY TERM mode\n"
91
" -a Emulate the gui simple search in ALL TERMS mode\n"
92
" -f Emulate the gui simple search in filename mode\n"
90
" -o Emulate the GUI simple search in ANY TERM mode\n"
91
" -a Emulate the GUI simple search in ALL TERMS mode\n"
92
" -f Emulate the GUI simple search in filename mode\n"
93
" -q is just ignored (compatibility with the recoll GUI command line)\n"
93
94
"Common options:\n"
94
95
" -c <configdir> : specify config directory, overriding $RECOLL_CONFDIR\n"
95
96
" -d also dump file contents\n"
96
" -n <cnt> limit the maximum number of results (0->no limit, default 2000)\n"
97
" -n [first-]<cnt> define the result slice. The default value for [first]\n"
98
" is 0. Without the option, the default max count is 2000.\n"
99
" Use n=0 for no limit\n"
97
100
" -b : basic. Just output urls, no mime types or titles\n"
98
101
" -Q : no result lines, just the processed query and result count\n"
99
" -m : dump the whole document meta[] array\n"
102
" -m : dump the whole document meta[] array for each result\n"
100
103
" -A : output the document abstracts\n"
101
" -S fld : sort by field name\n"
104
" -S fld : sort by field <fld>\n"
102
105
" -D : sort descending\n"
103
106
" -i <dbdir> : additional index, several can be given\n"
104
107
" -e use url encoding (%xx) for urls\n"
181
185
case 'l': op_flags |= OPT_l; break;
182
186
case 'm': op_flags |= OPT_m; break;
183
187
case 'n': op_flags |= OPT_n; if (argc < 2) Usage();
184
limit = atoi(*(++argv));
185
if (limit <= 0) limit = INT_MAX;
189
string rescnt = *(++argv);
190
string::size_type dash = rescnt.find("-");
191
if (dash != string::npos) {
192
firstres = atoi(rescnt.substr(0, dash).c_str());
193
if (dash < rescnt.size()-1) {
194
maxcount = atoi(rescnt.substr(dash+1).c_str());
197
maxcount = atoi(rescnt.c_str());
199
if (maxcount <= 0) maxcount = INT_MAX;
187
202
case 'o': op_flags |= OPT_o; break;
188
203
case 'P': op_flags |= OPT_P; break;
189
204
case 'q': op_flags |= OPT_q; break;
307
322
int cnt = query.getResCnt();
308
323
if (!(op_flags & OPT_b)) {
309
324
cout << "Recoll query: " << rq->getDescription() << endl;
311
cout << cnt << " results" << endl;
313
cout << cnt << " results (printing " << limit << " max):" << endl;
327
cout << cnt << " results" << endl;
329
cout << cnt << " results (printing " << maxcount << " max):"
332
cout << "Printing at most " << cnt - (firstres+maxcount) <<
333
" results from first " << firstres << endl;
315
336
if (op_flags & OPT_Q)
316
337
cout << "Query setup took " << chron.millis() << " mS" << endl;
320
cerr << "Can't create temporary directory: " <<
321
tmpdir.getreason() << endl;
325
339
if (op_flags & OPT_Q)
328
for (int i = 0; i < limit; i++) {
342
for (int i = firstres; i < firstres + maxcount; i++) {
330
344
if (!query.getDoc(i, doc))
341
355
if (op_flags & OPT_b) {
342
356
cout << doc.url << endl;
358
string titleorfn = doc.meta[Rcl::Doc::keytt];
359
if (titleorfn.empty())
360
titleorfn = doc.meta[Rcl::Doc::keyfn];
345
363
sprintf(cpc, "%d", doc.pc);
347
365
<< doc.mimetype << "\t"
348
366
<< "[" << doc.url << "]" << "\t"
349
<< "[" << doc.meta[Rcl::Doc::keytt] << "]" << "\t"
367
<< "[" << titleorfn << "]" << "\t"
350
368
<< doc.fbytes << "\tbytes" << "\t"
352
370
if (op_flags & OPT_m) {