[Xapian-discuss] Question on "single writer, multiple reader"

Gang Chen pkuchengang at gmail.com
Fri Jan 16 07:39:06 GMT 2015


Hi, dear Xapianers!

    I've been using Xapian in my project recently. The feature "single
writer, multiple reader" is one of my favorite, but currently I can't make
it work.

    My goal is to add more documents to the database increamentally, while
the Xapian search process is not stopped.

    I followed "quickstartindex.cc" and "quickstartsearch.cc" on the
website (http://xapian.org/docs/quickstart.html), and added a while loop
reading in query text around the core logic of the search process, in order
to simulate the online situation. (code snippet attatched below)

    Here is my question:

        With the search process alive, I added some new documents into the
database, but I can't retrieve them on the search process. However, if I
stop the search process and restart it again, I can retrieve those new ones.

    Could you tell me where I went wrong? How can I make increamental
modifications without stopping the search service?
    Thanks a lot :)

Best regards,
Gang Chen


=================================
// code snippet for the while loop in quickstartsearch.cc

Xapian::Database db(argv[1]);
Xapian::Enquire enquire(db);
while (true) {
            string line;
            getline(cin, line);
            Xapian::Query query(line);
            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
            Xapian::MSet matches = enquire.get_mset(0, 10);

            // Display the results
            cout << matches.size() << " results found" << endl;
            for (Xapian::MSetIterator i = matches.begin(); i !=
matches.end(); ++i) {
                Xapian::Document doc = i.get_document();
                cout << "Document ID " << *i << "\t" <<
                        i.get_percent() << "% [" <<
                        doc.get_data() << "]" << endl;
            }
}


More information about the Xapian-discuss mailing list