[Xapian-discuss] Adding an rset to a query

Olly Betts olly at survex.com
Fri Nov 26 02:39:38 GMT 2004

On Fri, Nov 26, 2004 at 03:17:55PM -0800, Ben Nolan wrote:
> I'm using xapian here with the perl api - can someone show me how I'm 
> meant to refine a query using an rset? Something like:
> my $rset = new Search::Xapian::QueryParser();

                                 ^^^^^^^^^^^ RSet, not QueryParser!

> $rset->addDocument(120);
> $rset->addDocument(163);
> $rset->addDocument(023);

         ^^^^^^^^^^^ add_document, not addDocument

And perl will treat 023 is octal, which I doubt was intended.  But this
probably isn't real code anyway...

> my $enq = $db->enquire( $qp->parse_string ($terms), $rset);

                                                    ^^^^^^^ don't pass here

And then you can get an ESet like this:

my $eset = $enq->get_eset(20, $rset);

And read terms from the ESet like this:

for (my $i = $eset->begin(); $i != $eset->end(); ++$i) {
    print $i->get_weight(), "\t", $i->get_termname(), "\n";

Although I've not tested the above as I don't currently have the perl
bindings built.


More information about the Xapian-discuss mailing list