[Xapian-discuss] Rqt for Features

Tim Brody tdb01r at ecs.soton.ac.uk
Fri Jul 9 15:59:16 BST 2004


Hi,

I've been working on a xapian implementation for the last month or so and
have implemented (well, hacked until it worked) QueryParser for Perl.

Could xapian have the ability to specify docids? My system - as I'm sure
many others do - maintains it's own ids for people, docs etc. For the moment
I've opted to rebuild the index from scratch everyday, rather than
maintaining a docid => myid mapping in order to perform incremental nightly
changes.

The cleanest method from outside of the API would be if replace_document
accepted a non-existent (to xapian) docid, in which case it adds the
document rather than excepting (i.e. SQL's "REPLACE" behaviour).

Having added wrappers for QueryParser I wonder whether it would be
worthwhile revising Stopper. I can't think of a situation where a stopper
would need to be more intelligent than containing a list of words to stop,
so seems a little pointless distributing a class in Xapian that doesn't do
this.

e.g. the class I've submitted to Alex:
class MyStopper : public Stopper
{
    public:
        bool operator()(const string &term) {
            return terms.find(term) != terms.end() ? terms[term] : false;
        };
        void add(string term) {
            terms[term] = true;
        };
        void del(string term) {
            terms[term] = false;
        };

    private:
        map<string,bool> terms;
};

Of course if I could wave a magic wand I would modify QueryParser's API
anyway .... :-)

class QueryParser {
public:
    QueryParser();
    ~QueryParser();
    set_database(&Xapian::Database);
    set_default_op(Query::op);
    set_stemmer(&Xapian::Stemmer,bool);
    add_stopword(&string);
    add_prefix(&string,&string);
    parse(&string);
    <get methods for termlist, stoplist, unstem etc>
private:
    ...
};

All the best,
Tim.




More information about the Xapian-discuss mailing list