[KinoSearch] Syntax for RangeQuery parsed by QueryParser

Marvin Humphrey marvin at rectangular.com
Tue Apr 28 12:25:54 PDT 2009


On Tue, Apr 28, 2009 at 11:19:31AM -0400, Darian Anthony Patrick wrote:

> Do you have any ideas about how such syntax should appear in a query string?  

My general philosophy on range searches is that they don't belong in query
strings. :)  I prefer separate input boxes when feasible.

> I've been considering:
> 
> 975 < field1: < 999
> 
> or
> 
> field1:<999 AND field1:>975
> 
> or
> 
> field1<999 AND field1>975
> 
> Both of these seem kind of awkward, but I think the last is easiest to
> parse, and doesn't conflict with term queries.  However, all are
> ignoring inclusivity/exclusivity.  Thoughts?

Lucene and Solr both use a TO operator and brackets.  Solr's syntax is more
featureful.

Inclusive ranges are denoted by square brackets, and exclusive ranges are
denoted by curly brackets.

  foo:[a TO z]
  foo:[* TO z]
  foo:[a TO *]
  foo:[* TO *]

  foo:{a TO z}
  foo:{* TO z}
  foo:{a TO *}
  foo:{* TO *}

http://lucene.apache.org/java/2_4_1/queryparsersyntax.html
http://wiki.apache.org/solr/SolrQuerySyntax

However, all of these conventions require user training, which is why I
generally prefer "advanced search" interfaces with separate boxes, dropdown
menus, etc.

> Also, I think there's an error in the version of that document currently
> published on rectangular.com.  In sub _tokenize() in the elsif
> condition, the regex
> 
> s/^"([^"]*)(?:"|$)//
> 
> does not collect the quotation marks into $1, causing the first if
> conditional in sub parse() to fail.

Thank you, I've updated that document with r4513.  :)

Marvin Humphrey



More information about the kinosearch mailing list