lucy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Karman <>
Subject Re: [lucy-user] Range queries in Lucy
Date Wed, 25 Jul 2012 13:42:53 GMT
On 7/25/12 6:33 AM, Nikola Tulechki wrote:
> Hello,
> Is there a way to specify range queries or query numerical fields like
> dates or user age in lucy using<  <=>  operators and integrate it in a
> normal query tree object.
> Thanks


You can create a RangeQuery:

The Lucy QueryParser doesn't support native syntax for that though, so 
if you want a query parser that does, you might want to look at:

where you can do things like:

  my $parser = Search::Query->parser( dialect => 'Lucy' );
  my $query  = $parser->parse( 'foo=(123..456)' );
  # then pass to Lucy
  my $hits  = $lucy_searcher->hits( query => $query->as_lucy_query() );

An important thing to note is that Lucy has only one public field 
storage type, which is a string. So if you want to get coherent results 
from a range query, make sure you are searching fixed-width strings. 
E.g., I format all my dates as YYYYMMDD so that I can do range queries like:

  my $all_hits_in_2012 = $parser->parse( 'mydate=(20120101..20121231)' );


Peter Karman  .  .

View raw message