*** empty log message ***
This commit is contained in:
parent
1d683ad411
commit
2ca3f087ab
@ -1,7 +1,7 @@
|
|||||||
depth = ..
|
depth = ..
|
||||||
include $(depth)/mk/sysconf
|
include $(depth)/mk/sysconf
|
||||||
|
|
||||||
PROGS = xadump rclqlang #trhist qtry qxtry
|
PROGS = xadump wasatorcl #trhist qtry qxtry
|
||||||
|
|
||||||
all: $(PROGS)
|
all: $(PROGS)
|
||||||
|
|
||||||
@ -14,11 +14,6 @@ xadump : $(XADUMP_OBJS)
|
|||||||
$(CXX) $(ALL_CXXFLAGS) -o xadump $(XADUMP_OBJS) \
|
$(CXX) $(ALL_CXXFLAGS) -o xadump $(XADUMP_OBJS) \
|
||||||
$(LIBICONV) $(LIBXAPIAN) $(LIBSYS)
|
$(LIBICONV) $(LIBXAPIAN) $(LIBSYS)
|
||||||
|
|
||||||
RCLQLANG_OBJS= rclqlang.o $(BIGLIB)
|
|
||||||
rclqlang : $(RCLQLANG_OBJS)
|
|
||||||
$(CXX) $(ALL_CXXFLAGS) -o rclqlang $(RCLQLANG_OBJS) \
|
|
||||||
$(LIBICONV) $(LIBXAPIAN) $(LIBSYS)
|
|
||||||
|
|
||||||
HISTORY_OBJS= trhist.o $(BIGLIB) $(MIMELIB)
|
HISTORY_OBJS= trhist.o $(BIGLIB) $(MIMELIB)
|
||||||
trhist : $(HISTORY_OBJS)
|
trhist : $(HISTORY_OBJS)
|
||||||
$(CXX) $(ALL_CXXFLAGS) -o trhist $(HISTORY_OBJS) \
|
$(CXX) $(ALL_CXXFLAGS) -o trhist $(HISTORY_OBJS) \
|
||||||
@ -34,6 +29,14 @@ trwasastrtoq.o : wasastringtoquery.cpp wasastringtoquery.h
|
|||||||
$(CXX) $(ALL_CXXFLAGS) -DTEST_WASASTRINGTOQUERY -c \
|
$(CXX) $(ALL_CXXFLAGS) -DTEST_WASASTRINGTOQUERY -c \
|
||||||
-o trwasastrtoq.o wasastringtoquery.cpp
|
-o trwasastrtoq.o wasastringtoquery.cpp
|
||||||
|
|
||||||
|
WASATORCL_OBJS= trwasatorcl.o $(BIGLIB) $(MIMELIB)
|
||||||
|
wasatorcl : $(WASATORCL_OBJS)
|
||||||
|
$(CXX) $(ALL_CXXFLAGS) -o wasatorcl $(WASATORCL_OBJS) \
|
||||||
|
$(LIBICONV) $(LIBXAPIAN)
|
||||||
|
trwasatorcl.o : wasatorcl.cpp wasatorcl.h
|
||||||
|
$(CXX) $(ALL_CXXFLAGS) -DTEST_WASATORCL -c \
|
||||||
|
-o trwasatorcl.o wasatorcl.cpp
|
||||||
|
|
||||||
$(BIGLIB): force
|
$(BIGLIB): force
|
||||||
cd $(depth)/lib;$(MAKE)
|
cd $(depth)/lib;$(MAKE)
|
||||||
force:
|
force:
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: wasatorcl.cpp,v 1.3 2007-01-17 13:53:41 dockes Exp $ (C) 2006 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: wasatorcl.cpp,v 1.4 2007-01-17 14:06:22 dockes Exp $ (C) 2006 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
#ifndef TEST_WASATORCL
|
#ifndef TEST_WASATORCL
|
||||||
|
|
||||||
@ -77,88 +77,106 @@ Rcl::SearchData *wasaQueryToRcl(WasaQuery *wasa)
|
|||||||
|
|
||||||
#else // TEST
|
#else // TEST
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
// Takes a query expressed in wasabi/recoll simple language and run it
|
||||||
#include "autoconfig.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <signal.h>
|
#include <stdlib.h>
|
||||||
#include <sys/stat.h>
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include "debuglog.h"
|
|
||||||
#include "rclinit.h"
|
|
||||||
#include "rclconfig.h"
|
|
||||||
#include "rcldb.h"
|
#include "rcldb.h"
|
||||||
#include "searchdata.h"
|
#include "rclconfig.h"
|
||||||
#include "refcntr.h"
|
#include "pathut.h"
|
||||||
|
#include "rclinit.h"
|
||||||
|
#include "debuglog.h"
|
||||||
#include "wasastringtoquery.h"
|
#include "wasastringtoquery.h"
|
||||||
#include "wasatorcl.h"
|
#include "wasatorcl.h"
|
||||||
|
|
||||||
static char *thisprog;
|
static char *thisprog;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
static char usage [] =
|
||||||
|
"rclqlang <query>\n"
|
||||||
|
" query may be like: \n"
|
||||||
|
" implicit AND, Exclusion, field spec: t1 -t2 title:t3\n"
|
||||||
|
" OR has priority: t1 OR t2 t3 OR t4 means (t1 OR t2) AND (t3 OR t4)\n"
|
||||||
|
" Phrase: \"t1 t2\" (needs additional quoting on cmd line)\n"
|
||||||
|
;
|
||||||
|
|
||||||
|
static void
|
||||||
|
Usage(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: usage:\n%s", thisprog, usage);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern bool runQuery(Rcl::Db&, const string& qs);
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
thisprog = argv[0];
|
thisprog = argv[0];
|
||||||
argc--; argv++;
|
argc--; argv++;
|
||||||
|
|
||||||
if (argc != 1) {
|
if (argc < 1)
|
||||||
fprintf(stderr, "need one arg\n");
|
Usage();
|
||||||
return 1;
|
string qs;
|
||||||
|
while (argc--) {
|
||||||
|
qs += *argv++;
|
||||||
|
if (argc)
|
||||||
|
qs += " ";
|
||||||
}
|
}
|
||||||
const string str = *argv++;argc--;
|
|
||||||
string reason;
|
|
||||||
|
|
||||||
RclConfig *config = recollinit(RCLINIT_NONE, 0, 0, reason, 0);
|
|
||||||
if (config == 0 || !config->ok()) {
|
|
||||||
cerr << "Configuration problem: " << reason << endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
string dbdir = config->getDbDir();
|
|
||||||
if (dbdir.empty()) {
|
|
||||||
cerr << "Configuration problem: " << "No dbdir" << endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
Rcl::Db rcldb;
|
Rcl::Db rcldb;
|
||||||
if (!rcldb.open(dbdir, Rcl::Db::DbRO, 0)) {
|
RclConfig *rclconfig;
|
||||||
cerr << "Could not open database in " << dbdir << endl;
|
string dbdir;
|
||||||
return 1;
|
string reason;
|
||||||
|
rclconfig = recollinit(0, 0, reason, 0);
|
||||||
|
if (!rclconfig || !rclconfig->ok()) {
|
||||||
|
fprintf(stderr, "Recoll init failed: %s\n", reason.c_str());
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
dbdir = rclconfig->getDbDir();
|
||||||
StringToWasaQuery qparser;
|
|
||||||
WasaQuery *wq = qparser.stringToQuery(str, reason);
|
|
||||||
if (wq == 0) {
|
|
||||||
fprintf(stderr, "wasastringtoquery failed: %s\n", reason.c_str());
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
string desc;
|
|
||||||
wq->describe(desc);
|
|
||||||
cout << endl << "Wasabi query description: " << desc << endl << endl;
|
|
||||||
|
|
||||||
Rcl::SearchData *sdata = wasatorcl(wq);
|
rcldb.open(dbdir, Rcl::Db::DbRO, Rcl::Db::QO_STEM);
|
||||||
RefCntr<Rcl::SearchData> rq(sdata);
|
if (!runQuery(rcldb, qs))
|
||||||
if (!rcldb.setQuery(rq)) {
|
exit(1);
|
||||||
cerr << "setQuery failed" << endl;
|
exit(0);
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
int maxi = rcldb.getResCnt() > 10 ? 10 : rcldb.getResCnt();
|
|
||||||
|
|
||||||
cout << endl << "Rcl Query description: " << sdata->getDescription()
|
|
||||||
<< endl << endl << "Results: " << endl;
|
|
||||||
|
|
||||||
for (int i = 0; i < maxi ; i++) {
|
|
||||||
Rcl::Doc doc;
|
|
||||||
if (!rcldb.getDoc(i, doc)) {
|
|
||||||
cerr << "getDoc failed" << endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
cout << i << ": " << doc.url << endl;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool runQuery(Rcl::Db &rcldb, const string &qs)
|
||||||
|
{
|
||||||
|
StringToWasaQuery parser;
|
||||||
|
string reason;
|
||||||
|
WasaQuery *wq = parser.stringToQuery(qs, reason);
|
||||||
|
RefCntr<Rcl::SearchData> rq(wasaQueryToRcl(wq));
|
||||||
|
if (!rq.getptr())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
rcldb.setQuery(rq);
|
||||||
|
int offset = 0;
|
||||||
|
int limit = 100;
|
||||||
|
cout << "Recoll query: " << rq->getDescription() << endl;
|
||||||
|
cout << rcldb.getResCnt() << " results (printing 100 max):" << endl;
|
||||||
|
for (int i = offset; i < offset + limit; i++) {
|
||||||
|
int pc;
|
||||||
|
Rcl::Doc doc;
|
||||||
|
if (!rcldb.getDoc(i, doc, &pc))
|
||||||
|
break;
|
||||||
|
|
||||||
|
char cpc[20];
|
||||||
|
sprintf(cpc, "%d", pc);
|
||||||
|
cout << cpc << "% "
|
||||||
|
<< doc.mimetype.c_str() << " "
|
||||||
|
<< doc.dmtime.c_str() << " "
|
||||||
|
<< doc.fbytes.c_str() << " bytes "
|
||||||
|
<< "[" << doc.url.c_str() << "] "
|
||||||
|
<< "[" << doc.title.c_str() << "] "
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // TEST_WASATORCL
|
#endif // TEST_WASATORCL
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user