You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Chris Hostetter <ho...@fucit.org> on 2006/12/13 21:03:53 UTC

'New' "Date Math" parsing code in Solr

(I have this nasty habit of commiting cool things to Solr that should be
announced on solr-user, and then deciding I'll wait untill they are in a
nightly snapshot before I send an email about them -- and then forgetting
that I never sent the mail).

A while back I added some functionality to the DateField class which
extends it's parsing abilities so that it can recognize strings like
"NOW", "NOW+1DAY", "NOW+1DAY-3HOURS", and even "NOW/MONTH+3MONTHS" which
means round down to the nearest month, then add three months.

You can play with this syntax and see what exactly it does with various
inputs by looking at the "parsedquery" debug info for any date field, if
you are running the example config from Solr something like this will
work...

http://localhost:8983/solr/select?version=2.1&q=field_dt%3A%5BNOW+TO+NOW%2FDAY%2B1MONTH%5D&start=0&rows=0&debugQuery=on

This syntax was added to not only make it easier to run quick data
inspection queries like "startDate:[NOW TO *]" but also so that *relative*
date based queries can be included directly in the default query options
for request handlers configured in solrconfig.xml.  For example, if you
only want to let people search articles less then a month old, you could
put...

     <str name="fq">pubDate:[NOW/DAY-1MONTH]</str>

...in your requestHandler config, and that cached filter query will be
reusable for 24 hours.

This syntax is supported anywhere Solr parses a DateField, so it can even
be used in <field> values when sending <add><doc> messages.

More info can be found in the javadocs...

http://incubator.apache.org/solr/docs/api/org/apache/solr/schema/DateField.html
http://incubator.apache.org/solr/docs/api/org/apache/solr/util/DateMathParser.html


-Hoss


Re: Strange Sorting results on a Text Field

Posted by Chris Hostetter <ho...@fucit.org>.
: Despite considerations of stemming and such for "text"
: type fields, is it the case that
: if we have a single value "text" type field,
: will sorting work, though?

correct ... KeywordTokenizer with Filters of your choice should produce a
sortable string of whatever form you desire.



-Hoss


Re: Strange Sorting results on a Text Field

Posted by Tracey Jaquith <tr...@archive.org>.
Despite considerations of stemming and such for "text"
type fields, is it the case that 
if we have a single value "text" type field,
will sorting work, though?

--tracey

On 9/11/06, Tom Weber <[EMAIL PROTECTED]> wrote:

   Thanks also for the "multiValued" explanation, this is useful for
my current application. But then, if I use this field and I ask for
sorting, how will the sorting be done, alphanumeric on the first
entry for this field ? Until now, I entered more than one entry by
separting them with a space in the same field, like <field
name="test">text1 text2 text3</field>.
  

Sorting is currently only supported when there is at most one value
(or token) per document.  This is a lucene restriction.

-Yonik