[Xapian-discuss] using xapian for indexing mails

Matthew Somerville matthew at mysociety.org
Sat Aug 30 10:29:27 BST 2008


djcb wrote:
> Or is there some easier way to simply provide blobs of text, and being
> able to search for them later?

You want XapianTermGenerator, which takes a blob of text and adds all the
words in it to Xapian. e.g. (snippet of the written-in-PHP
http://sandwich.ukcod.org.uk/~matthew/subtitles/?source=1#indexer ):

$indexer = new XapianTermGenerator();
$indexer->set_flags(128);
$indexer->set_database($db); # For spelling

[... then for each document ... ]

$doc = new XapianDocument();
$indexer->set_document($doc);
$doc->set_data( [...] );
$doc->add_term( [...] );
$doc->add_value( [...] );
$indexer->index_text($text);
$db->add_document($doc);

ATB,
Matthew



More information about the Xapian-discuss mailing list