[Xapian-discuss] Query::MatchAll

Allen daineng at gmail.com
Mon Oct 6 12:07:54 BST 2008


O.K. here is the quickstartindex.cpp

#include <xapian.h>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    if (argc < 4) {
        cout << "usage: " << argv[0] << "<path to database>" <<
            " <document data> <document terms>" << endl;
        return EXIT_FAILURE;
    }

    try {
        Xapian::WritableDatabase database(argv[1],
Xapian::DB_CREATE_OR_OPEN);
        Xapian::Document newdocument;
        newdocument.set_data(string(argv[2]));
        for (int i(3); i < argc; ++i) {
            newdocument.add_posting(argv[i], i-2);
        }
        database.add_document(newdocument);
    }
    catch (const Xapian::Error &e) {
        cout << "Xapian.Error: " << e.get_msg() << endl;
    }

    return EXIT_SUCCESS;
}

and the quickstartsearchall.cpp

#include <xapian.h>
#include <iostream>

using namespace std;
using namespace Xapian;

int main(int argc, char *argv[])
{
    if (argc < 2) {
        cout << "usage: " << argv[0] << " <path to database>" << endl;
        return EXIT_FAILURE;
    }

    try {
        Database db(argv[1]);
        Enquire enquire(db);
        enquire.set_query(Query::MatchAll);
        MSet matches = enquire.get_mset(0, 10);
        cout << matches.size() << " results found" << endl;
        for (MSetIterator i = matches.begin(); i != matches.end(); i++) {
            Document doc = i.get_document();
            cout << "#" << *i << "\t" << i.get_percent() << "% [" <<
                doc.get_data() << "]" << endl;
        }
    }
    catch (const Error &e) {
        cout << "Xapian.Error: " << e.get_msg() << endl;
    }

    return EXIT_SUCCESS;
}


2008/10/6 Olly Betts <olly at survex.com>

> On Mon, Oct 06, 2008 at 06:49:38PM +0800, Allen wrote:
> > The sources come from http://www.xapian.org/docs/quickstart.html, and in
> > quickstartsearchall, like quickstartsearch, but query replaced by
> > Query::MatchAll
>
> Since you actually have the source file which demonstrates this problem
> on your hard disk, please save me the time having to glue together the
> code from that document and try to recreate the change you made - just
> attach your source code to your reply.  You know, like I asked you to do
> several messages ago...
>
> If I have to play "guess the example code" that wastes my time, and it
> also wastes yours when my attempt works for me and I need to ask you for
> more details (like it did in this case when I tried to recreate your
> problem by modifying quest.cc).
>
> Tracking down bugs can be a frustrating activity, especially when you
> can't reproduce an issue someone else can because they simply aren't
> providing enough information, even when it would actually be easier for
> them to do so than keep sending unhelpfully vague replies.
>
> Simon Tatham's essay on the subject is well worth a read if you don't
> understand my frustration:
>
> http://www.chiark.greenend.org.uk/~sgtatham/bugs.html<http://www.chiark.greenend.org.uk/%7Esgtatham/bugs.html>
>
> Cheers,
>     Olly
>


More information about the Xapian-discuss mailing list