[Xapian-discuss] value range in perl

Olly Betts olly at survex.com
Fri Oct 26 19:47:14 BST 2007


On Fri, Oct 26, 2007 at 02:08:42PM -0400, Jim Spath wrote:
> I think I figured out the problem after much digging and searching:
> 
> $qp->add_valuerangeprocessor(new 
> Search::Xapian::DateValueRangeProcessor(0));

If you're using 1.0.0.0 still, you need to assign the
DateValueRangeProcessor object to a variable with the same lifetime as
$qp or else it will be deleted by Perl - like so:

  my ($vrp, $qp);

[...]

  $vrp = new Search::Xapian::DateValueRangeProcessor(0);
  $qp->add_valuerangeprocessor($vrp);

1.0.1.0 "fixes" this by incrementing the reference count - this means
such objects are leaked at the moment, but that seems preferable to
crashing until I sort out a proper fix.

> I do have a followup question...
> 
> In our search application, the Search::Xapian::QueryParser object is 
> persistent.  Is there any kind of negative effect of having a value 
> range processor set in the parser object when it isn't actually needed?

There's a small overhead - if there are value range processors set, the
tokeniser checks the whole query string before it starts to see if it
contains "..".  If it doesn't, that's it.  If it does, then it scans
forward from each term to see if it's the start of a value range.

The check for ".." is a tiny overhead, and even the scanning forward
is a tiny amount of work compared to actually performing the search.
It's also likely this will be improved in the future.

> Most of our search requests will not be utilizing the date range option, 
> so I'm somewhat concerned about using an option that isn't necessary 
> most of the time.

Overall, it's not something to worry about.

Cheers,
    Olly



More information about the Xapian-discuss mailing list