[Xapian-discuss] seg fault on search
Michael Lewis
mal at icginc.com
Tue Jan 21 16:53:41 GMT 2014
I have written a very simple function to return the match count based on the simplesearch.cc code. It fails with a seg fault. The relevant code is:
--------------------
int ftQuery(char* qs, const char* dbname,char* results, int msize) {
long docid;
char* op;
char fullDB[1024];
string queryString;
sprintf(fullDB,"/var/lib/fulltext/%s",dbname);
queryString=qs;
try {
Database db;
db.add_database(Database(fullDB));
Enquire enquire(db);
try {
Xapian::QueryParser qp;
Xapian::Stem stemmer("english");
qp.set_database(db);
qp.set_default_op(Query::OP_OR);
qp.set_stemmer(stemmer);
qp.set_stemming_strategy(QueryParser::STEM_SOME);
Xapian::Query q=qp.parse_query(queryString);
...
As soon as it hits the q=qp.parse_query line it gets the seg fault.
The function is called like so:
int main (int argc, char* const argv[]) {
int i;
char results[100000];
if (argc<2) {
printf("Usage: tft 'query string'\n");
return 1;
}
I=ftQuery(argv[1],"testdb",results,2000);
printf("%d results returned\n",i);
return (0);
The query string is "austria" and it works with simplesearch.com. I have verified that the string is being passed to the function correctly as is the database name. I am out of ideas and wonder if anyone can point out anything that I am overlooking.
Thanks,
Michael Lewis
_____________________________________________
Xapian-discuss mailing list
Xapian-discuss at lists.xapian.org
http://lists.xapian.org/mailman/listinfo/xapian-discuss
More information about the Xapian-discuss
mailing list