[Xapian-discuss] How to choose the proximity between search words

Olly Betts olly at survex.com
Wed Jan 4 01:32:25 GMT 2012


On Tue, Jan 03, 2012 at 08:46:12AM +0000, Nat wrote:
> $queryOP = XapianQuery::OP_NEAR;
> $proximity = 30;
> 
> $queryparser->set_default_op(XapianQuery::OP_NEAR);
> $query = $queryparser->parse_query($searchexp,XapianQueryParser::FLAG_DEFAULT);

You can't currently set the window size used by QueryParser if you set
default_op to OP_NEAR.

> I've got my query, but I don't know how I can use Xapian::Query
> constructor or any function of this class to specify my $proximity.

If you build the phrase Query object by hand, you would do it like so:

$query = new XapianQuery(XapianQuery::OP_NEAR, array('hello', 'world'), 30);

Cheers,
    Olly



More information about the Xapian-discuss mailing list