[Xapian-discuss] In-memory databases vs PHP Bindings

Andrew Betts andrew.betts at assanka.net
Thu Oct 21 15:32:31 BST 2010


I can't quite connect the dots on this, perhaps someone can help.  I'm 
simply trying to create an in-memory database comprising a single document, 
so that I can run a load of queries against it and see if any of them match 
the new document (this is to enable users to have 'subscriptions' to saved 
searches and be alerted every time a new item is published that matches 
their search).

However, I can't work out how to create an in-memory database via the PHP 
bindings.  Here's what I've got so far, using a disk-based index with an 
automatic backend (third line from the end is the critical one):

// Find the document in the posts index
$xenq = new XapianEnquire($xdb_posts);
$xenq->set_query(new XapianQuery("UIDpost".$postid));
$xdoc = $xenq->get_mset(0, 1)->begin()->get_document();

// Create a database that just contains the one document
// TODO:AB:20101020: Work out how to build an in-memory Xapian database via 
PHP bindings
$xdb_doc = new XapianWritableDatabase(PROJROOT.'/tmp/xapian/doc'.$postid, 
Xapian::DB_CREATE_OR_OVERWRITE);
$xdb_doc->add_document($xdoc);
$xdb_doc->commit();


Also, FYI, the documentation here seems incomplete:
http://xapian.org/docs/apidoc/html/classXapian_1_1TermIterator.html

I had to inspect the bindings to find the rather useful get_term() method of 
the TermIterator class!  It does mention the use of the * operator to return 
the current term but I can't see how I'd invoke that in PHP.  If the 
get_term method applies in all environments, it ought to be documented I'd 
have thought.

Andrew




More information about the Xapian-discuss mailing list