#include<xapian.h>
#include<iostream>
#define QUERY "title:新闻 AND content:男篮"
using namespace std;
int main(int argc , char **argv){
try{
string querystring(QUERY);
Xapian::Database database(argv[1]);
Xapian::Enquireenquire(database);
Xapian::QueryParserqp;
qp.add_prefix("title", "T");
qp.add_prefix("content", "C");
Xapian::Queryquery = qp.parse_query(querystring);
cout<<"queryis: "<<query.get_description()<<endl;
enquire.set_query(query);
Xapian::MSetmatches = enquire.get_mset(0,10);
cout<<matches.get_matches_estimated()<<"result found"<<endl;
for(Xapian::MSetIteratorit = matches.begin() ; it != matches.end() ; it++){
Xapian::Documentdoc = it.get_document();
cout<<it.get_rank()<<":"<<it.get_percent()<<"%docid="<<*it<<" value="<<doc.get_value(1) <<",data"<<doc.get_data()<<endl;
}
}catch(constXapian::Error &e){
cout<<"exception:"<<e.get_description()<<endl;
}
}