[Xapian-discuss] Seek help with simple writer/search using Perl

Olly Betts olly at survex.com
Mon Apr 9 20:48:38 BST 2007


On Mon, Apr 09, 2007 at 03:32:38PM -0400, Jeff Anderson wrote:
> As you can see, i am storing each value via set_data(), add_posting(),
> and add_value() (i really have no idea what the differences are or why
> i need to use one instead of the other).

This is the nub of your problem!

The document data is opaque as far as Xapian is concerned.  Store
whatever you want there (typically you'd put things you need to display
a match to the user, like the title, a sample of text, etc).

A document "value" is a small piece of data which is stored such that
it can be accessed rapidly during the match, for things like sorting
by date, collapsing similar matches (same MD5 sum, same website, etc).

Calling add_posting() adds an index entry for the current document
with positional information (which allows phrase searching, etc).
You can also use add_term() to add an index entry without positional
information - this is commonly used for terms intended for boolean
filtering (e.g. you might add a term for "document language").  You
can also use add_term() for all index entries if you don't need to
support phrase searching.

So in your example, you'll only be able to search for terms "ONE"
and "TWO".  If you want "foo", "bar", etc to match, you need to
add them as terms (using add_posting() or add_term()) instead of
(or as well as) as values!

Cheers,
    Olly



More information about the Xapian-discuss mailing list