38 main(
int argc,
char **argv)
44 if (strcmp(argv[1],
"--version") == 0) {
45 cout <<
"simplesearch\n";
48 if (strcmp(argv[1],
"--help") == 0) {
52 cout <<
"Usage: " << argv[0] <<
" PATH_TO_DATABASE QUERY\n";
65 string query_string(argv[2]);
69 query_string += *argv++;
87 cout <<
"Matches 1-" << matches.
size() <<
":\n\n";
90 cout << i.get_rank() + 1 <<
": " << i.get_weight() <<
" docid=" << *i
91 <<
" [" << i.get_document().get_data() <<
"]\n\n";
static Xapian::Query query(Xapian::Query::op op, const string &t1=string(), const string &t2=string(), const string &t3=string(), const string &t4=string(), const string &t5=string(), const string &t6=string(), const string &t7=string(), const string &t8=string(), const string &t9=string(), const string &t10=string())
This class is used to access a database, or a group of databases.
This class provides an interface to the information retrieval system for the purpose of searching.
void set_query(const Xapian::Query &query, Xapian::termcount qlen=0)
Set the query to run.
MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems, Xapian::doccount checkatleast=0, const RSet *omrset=0, const MatchDecider *mdecider=0) const
Get (a portion of) the match set for the current query.
All exceptions thrown by Xapian are subclasses of Xapian::Error.
std::string get_description() const
Return a string describing this object.
Iterator over a Xapian::MSet.
Class representing a list of search results.
Xapian::doccount size() const
Return number of items in this MSet object.
MSetIterator begin() const
Return iterator pointing to the first item in this MSet.
MSetIterator end() const
Return iterator pointing to just after the last item in this MSet.
Xapian::doccount get_matches_estimated() const
Estimate of the total number of matching documents.
Build a Xapian::Query object from a user query string.
void set_database(const Database &db)
Specify the database being searched.
void set_stemmer(const Xapian::Stem &stemmer)
Set the stemmer.
void set_stemming_strategy(stem_strategy strategy)
Set the stemming strategy.
Query parse_query(const std::string &query_string, unsigned flags=FLAG_DEFAULT, const std::string &default_prefix=std::string())
Parse a query.
Class representing a query.
std::string get_description() const
Return a string describing this object.
Class representing a stemming algorithm.
int main(int argc, char **argv)
static Xapian::Stem stemmer
Public interfaces for the Xapian library.