fix executesd
This commit is contained in:
parent
667daba8fa
commit
d282f8a838
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: pyrecoll.cpp,v 1.19 2008-10-10 08:05:11 dockes Exp $ (C) 2007 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: pyrecoll.cpp,v 1.20 2008-10-10 08:18:27 dockes Exp $ (C) 2007 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ SearchData_addclause(recoll_SearchDataObject* self, PyObject *args,
|
|||||||
char *fld = 0; // needs freeing
|
char *fld = 0; // needs freeing
|
||||||
int dostem = 1; // needs freeing
|
int dostem = 1; // needs freeing
|
||||||
recoll_SearchDataObject *sub = 0;
|
recoll_SearchDataObject *sub = 0;
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ses|iesO!", kwlist,
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ses|iesiO!", kwlist,
|
||||||
&tp, "utf-8", &qs, &slack,
|
&tp, "utf-8", &qs, &slack,
|
||||||
"utf-8", &fld, &dostem,
|
"utf-8", &fld, &dostem,
|
||||||
&recoll_SearchDataType, &sub))
|
&recoll_SearchDataType, &sub))
|
||||||
@ -665,7 +665,7 @@ Query_execute(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(doc_Query_executesd,
|
PyDoc_STRVAR(doc_Query_executesd,
|
||||||
"execute(SearchData)\n"
|
"executesd(SearchData)\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Starts a search for the query defined by the SearchData object.\n"
|
"Starts a search for the query defined by the SearchData object.\n"
|
||||||
);
|
);
|
||||||
@ -676,17 +676,19 @@ Query_executesd(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
|
|||||||
static char *kwlist[] = {"searchdata", NULL};
|
static char *kwlist[] = {"searchdata", NULL};
|
||||||
recoll_SearchDataObject *pysd = 0;
|
recoll_SearchDataObject *pysd = 0;
|
||||||
LOGDEB(("Query_executeSD\n"));
|
LOGDEB(("Query_executeSD\n"));
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!|i:Query_execute", kwlist,
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:Query_execute",
|
||||||
|
kwlist,
|
||||||
&recoll_SearchDataType, &pysd)) {
|
&recoll_SearchDataType, &pysd)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (self->query == 0 ||
|
if (pysd == 0 || self->query == 0 ||
|
||||||
the_queries.find(self->query) == the_queries.end()) {
|
the_queries.find(self->query) == the_queries.end()) {
|
||||||
PyErr_SetString(PyExc_AttributeError, "query");
|
PyErr_SetString(PyExc_AttributeError, "query");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
string sf = self->sortfield ? string(self->sortfield) : string("");
|
string sf = self->sortfield ? string(self->sortfield) : string("");
|
||||||
self->query->setSortBy(sf, self->ascending);
|
self->query->setSortBy(sf, self->ascending);
|
||||||
|
self->query->setQuery(pysd->sd);
|
||||||
int cnt = self->query->getResCnt();
|
int cnt = self->query->getResCnt();
|
||||||
self->next = 0;
|
self->next = 0;
|
||||||
return Py_BuildValue("i", cnt);
|
return Py_BuildValue("i", cnt);
|
||||||
|
|||||||
@ -94,6 +94,8 @@ class mbox_indexer:
|
|||||||
#print "Simple: " + ct
|
#print "Simple: " + ct
|
||||||
if ct.lower() == "text/plain":
|
if ct.lower() == "text/plain":
|
||||||
charset = part.get_content_charset("iso-8859-1")
|
charset = part.get_content_charset("iso-8859-1")
|
||||||
|
print "charset: ", charset
|
||||||
|
print "text: ", part.get_payload(None, True)
|
||||||
text += unicode(part.get_payload(None, True), charset)
|
text += unicode(part.get_payload(None, True), charset)
|
||||||
doc.text = text
|
doc.text = text
|
||||||
# dbytes
|
# dbytes
|
||||||
|
|||||||
@ -7,7 +7,7 @@ def dotest(db, q):
|
|||||||
query = db.query()
|
query = db.query()
|
||||||
query.sortby("title", 1)
|
query.sortby("title", 1)
|
||||||
|
|
||||||
nres = query.executesd(q, stemming = 1)
|
nres = query.executesd(q)
|
||||||
print "Result count: ", nres
|
print "Result count: ", nres
|
||||||
if nres > 10:
|
if nres > 10:
|
||||||
nres = 10
|
nres = 10
|
||||||
@ -22,10 +22,10 @@ def dotest(db, q):
|
|||||||
# End dotest
|
# End dotest
|
||||||
|
|
||||||
sd = recoll.SearchData()
|
sd = recoll.SearchData()
|
||||||
sd.addClause("and", "essaouira maroc")
|
sd.addclause("and", "essaouira maroc")
|
||||||
#sd.addClause("and", "dockes", field="author")
|
#sd.addclause("and", "dockes", field="author")
|
||||||
#sd.addClause("phrase", "jean francois", 1)
|
#sd.addclause("phrase", "jean francois", 1)
|
||||||
#sd.addClause("excl", "plage")
|
#sd.addclause("excl", "plage")
|
||||||
|
|
||||||
db = recoll.connect()
|
db = recoll.connect()
|
||||||
dotest(db, sd)
|
dotest(db, sd)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user