/* quickstartsearch.cc: Simplest possible searcher */ #include <om/om.h> int main(int argc, char *argv[]) { // Simplest possible options parsing: we just require two or more // parameters. if(argc < 3) { cout << "usage: " << argv[0] << " <path to database> <search terms>" << endl; exit(1); } // Catch any OmError exceptions thrown try { // Make the database OmDatabase db(OmQuartz__open(argv[1])); // Start an enquire session OmEnquire enquire(db); // Build the query object OmQuery query(OmQuery::OP_OR, argv + 2, argv + argc); cout << "Performing query `" << query.get_description() << "'" << endl; // Give the query object to the enquire session enquire.set_query(query); // Get the top 10 results of the query OmMSet matches = enquire.get_mset(0, 10); // Display the results cout << matches.size() << " results found" << endl; for (OmMSetIterator i = matches.begin(); i != matches.end(); ++i) { OmDocument doc = i.get_document(); cout << "Document ID " << *i << "\t" << i.get_percent() << "% [" << doc.get_data() << "]" << endl; } } catch(const OmError &error) { cout << "Exception: " << error.get_msg() << endl; } }