Adding range filter to Solr

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding range filter to Solr

jason rutherglen-2
Where would this go in the code?  I want to add a new XML based request handler so that spans and range filters can be handled.  Thanks.

Reply | Threaded
Open this post in threaded view
|

Re: Adding range filter to Solr

Chris Hostetter-3

: Where would this go in the code?  I want to add a new XML based request
: handler so that spans and range filters can be handled.  Thanks.

Since RangeFilter is included in lucene 1.9 (as is SpanQuery) it's
automatically inlcuded in Solr .. in fact, the default SolrQueryParser
(used by the StandardRequestHandler) automaiclaly uses
COnstantScoreRangeQuery (a thin wrapper arround RangeFilter) instead of
RangeQuery.




-Hoss

Reply | Threaded
Open this post in threaded view
|

Re: Adding range filter to Solr

jason rutherglen-2
Are you saying that ConstantScoreRangeQuery is interpreted by the IndexSearcher to be the same as a filter?  

----- Original Message ----
From: Chris Hostetter <[hidden email]>
To: [hidden email]; jason rutherglen <[hidden email]>
Sent: Thursday, April 27, 2006 5:44:19 PM
Subject: Re: Adding range filter to Solr


: Where would this go in the code?  I want to add a new XML based request
: handler so that spans and range filters can be handled.  Thanks.

Since RangeFilter is included in lucene 1.9 (as is SpanQuery) it's
automatically inlcuded in Solr .. in fact, the default SolrQueryParser
(used by the StandardRequestHandler) automaiclaly uses
COnstantScoreRangeQuery (a thin wrapper arround RangeFilter) instead of
RangeQuery.




-Hoss




Reply | Threaded
Open this post in threaded view
|

Re: Adding range filter to Solr

Yonik Seeley
On 4/27/06, jason rutherglen <[hidden email]> wrote:
> Are you saying that ConstantScoreRangeQuery is interpreted by the IndexSearcher to be the same as a filter?

A filter is a constraint that can also be represented as a part of a query.

field1:term1 field2:term2 filtered by field3:[a TO b] can be transformed to
+(field1:term1 field2:term2) +field3:[a TO b]^0


-Yonik
Reply | Threaded
Open this post in threaded view
|

Re: Adding range filter to Solr

jason rutherglen-2
This is a little bit confusing for me, the documentation at http://lucene.apache.org/java/docs/queryparsersyntax.html states they query format you described is a Range Query however this document in the wiki indicates there is a difference between filters and range queries http://wiki.apache.org/jakarta-lucene/DateRangeQueries  Also for +(datemodified:[20051228 TO 20060428]) I am receiving:

org.apache.solr.core.SolrException: Invalid Date String:'20051228'
        at org.apache.solr.schema.DateField.toInternal(DateField.java:72)
        at org.apache.solr.search.SolrQueryParser.getRangeQuery(SolrQueryParser.java:55)
        at org.apache.lucene.queryParser.QueryParser.getRangeQuery(QueryParser.java:500)
        at org.apache.lucene.queryParser.QueryParser.Term(QueryParser.java:1016)
        at org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:848)
        at org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:791)
        at org.apache.lucene.queryParser.QueryParser.Clause(QueryParser.java:852)
        at org.apache.lucene.queryParser.QueryParser.Query(QueryParser.java:819)
        at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:140)
        at org.apache.solr.search.QueryParsing.parseQuery(QueryParsing.java:47)
        at org.apache.solr.search.QueryParsing.parseQuery(QueryParsing.java:42)
        at org.apache.solr.request.StandardRequestHandler.handleRequest(StandardRequestHandler.java:89)
        at org.apache.solr.core.SolrCore.execute(SolrCore.java:600)

----- Original Message ----
From: Yonik Seeley <[hidden email]>
To: [hidden email]; jason rutherglen <[hidden email]>
Sent: Thursday, April 27, 2006 7:50:04 PM
Subject: Re: Adding range filter to Solr

On 4/27/06, jason rutherglen <[hidden email]> wrote:
> Are you saying that ConstantScoreRangeQuery is interpreted by the IndexSearcher to be the same as a filter?

A filter is a constraint that can also be represented as a part of a query.

field1:term1 field2:term2 filtered by field3:[a TO b] can be transformed to
+(field1:term1 field2:term2) +field3:[a TO b]^0


-Yonik



Reply | Threaded
Open this post in threaded view
|

Re: Adding range filter to Solr

Chris Hostetter-3

: This is a little bit confusing for me, the documentation at
: http://lucene.apache.org/java/docs/queryparsersyntax.html states they
: query format you described is a Range Query however this document in the
: wiki indicates there is a difference between filters and range queries
: http://wiki.apache.org/jakarta-lucene/DateRangeQueries Also for

As I mentioned in my last reply, the difference between the
SolrQueryParser and the default Lucene QueryParser is that Solr
automatically replaces RangeQueries with ConstantScoreRangeQueries --
which is implimented as a RangeFilter under the covers.

: +(datemodified:[20051228 TO 20060428]) I am receiving:

if you indexed your dates as strings in that format, that would work fine,
but it appears you are using Solr's special DateField, which is good
because it allows a high level of precisiosn, but it's also a very rigid
format.  The sample schema.xml in the example describes the format that
should be used...

    <!-- The format for this date field is of the form 1995-12-31T23:59:59Z, and
         is a more restricted form of the canonical representation of dateTime
         http://www.w3.org/TR/xmlschema-2/#dateTime
         The trailing "Z" designates UTC time and is mandatory.
         Optional fractional seconds are allowed: 1995-12-31T23:59:59.999Z
         All other components are mandatory. -->

...but this info doesnt seem to have ever made it into the javadocs for
the DateField type ... i'll rectify that.



-Hoss

Reply | Threaded
Open this post in threaded view
|

Re: Adding range filter to Solr

jason rutherglen-2
Thanks that works well.

----- Original Message ----
From: Chris Hostetter <[hidden email]>
To: Solr Dev <[hidden email]>; jason rutherglen <[hidden email]>
Sent: Friday, April 28, 2006 1:58:57 PM
Subject: Re: Adding range filter to Solr


: This is a little bit confusing for me, the documentation at
: http://lucene.apache.org/java/docs/queryparsersyntax.html states they
: query format you described is a Range Query however this document in the
: wiki indicates there is a difference between filters and range queries
: http://wiki.apache.org/jakarta-lucene/DateRangeQueries Also for

As I mentioned in my last reply, the difference between the
SolrQueryParser and the default Lucene QueryParser is that Solr
automatically replaces RangeQueries with ConstantScoreRangeQueries --
which is implimented as a RangeFilter under the covers.

: +(datemodified:[20051228 TO 20060428]) I am receiving:

if you indexed your dates as strings in that format, that would work fine,
but it appears you are using Solr's special DateField, which is good
because it allows a high level of precisiosn, but it's also a very rigid
format.  The sample schema.xml in the example describes the format that
should be used...

    <!-- The format for this date field is of the form 1995-12-31T23:59:59Z, and
         is a more restricted form of the canonical representation of dateTime
         http://www.w3.org/TR/xmlschema-2/#dateTime
         The trailing "Z" designates UTC time and is mandatory.
         Optional fractional seconds are allowed: 1995-12-31T23:59:59.999Z
         All other components are mandatory. -->

...but this info doesnt seem to have ever made it into the javadocs for
the DateField type ... i'll rectify that.



-Hoss