[Xapian-discuss] Understanding API Documentation for PHP

Peter Van Dijk pvandijk at vision6.com.au
Wed Sep 21 00:23:36 BST 2011

On 21 September 2011 00:53, Sam Millman <sam.millman at gmail.com> wrote:

> I understand how to add documents etc etc etc and how to build queries but
> how I do specify in add_value what field type xapian should take (i.e.
> tokenized, unindexed, indexed)?

I'm not sure if i'm interpreting what you're saying correctly, but if you
want to tokenize or index things, you want to look towards
XapianTermGenerator::index_text instead.

Values are stored against the documents and aren't directly part of the
indexed text, so just set your class up with some basic constants, const
VALUE_X = 0; const VALUE_Y = 1;
and then pass them to add_value and get_value as required, ie.
$document->add_value(self::VALUE_X, $anything);  or

In a general sense is there any more programmer orientated
> documentation/tutorials rather than researcher orientated document than
> http://xapian.org/docs/ that better describes the steps of indexing and
> searching etc?

The docs arent really researcher oriented; the overview page is a good place
to start, as it describes how the api is used:

That being said, having recently worked on a PHP based deployment of Xapian
i can tell you i struggled somewhat with the same thing.
The PHP wrapper really doesn't clue you in as to what types you should be
passing to any given method, so you'll find yourself having to wrap a lot of
stuff with intval( ) or strval( ) for the methods to work correctly,
which is a side effect of trying to use a wrapper designed for a strongly
typed language with a loosely typed one.

That being said, the api docs are spot on for the most part, i'd recommend
cracking open xapian.php and reading it in line with
given any object in the api docs just look up it's declaration in xapian.php
and you should be able to figure out how to use it correctly, as all the
types are correctly listed in the documentation.

I'm not going to have a chance for a while, but if i get the opportunity i'd
like to write some docs for using Xapian in PHP for the wiki.

More information about the Xapian-discuss mailing list