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 tarjei <ta...@nu.no> on 2009/04/22 14:47:31 UTC

Sorting dates with reduced precision

Hi, I got a set of entries where I want to sort them both by the day 
they were entered into solr(stored as a Solr date)  and also by another 
field.

Is this possible or do I have to create a separate field with lower 
resolution?

kind regards,
Tarjei

RE: Sorting dates with reduced precision

Posted by Ensdorf Ken <En...@zoominfo.com>.
> >> Yes, but dates are fairly spesific, say 06:45 Nov. 2 , 2009. What if
> I
> >> want to say "Sort so that withing entries for Nov. 2 , you sort by
> >> relevance" for example?
> >>
> >
> > Append "/DAY" to the date value you index, for example
> >
> > "1995-12-31T23:59:59Z/DAY" will yield "1995-12-31"
> >
> > So that all documents with the same date will then be sorted by
> relevance or whatever you specify as the next criteria in the "sort"
> parameter.
> Thanks, this happens at indexing time?

Yes

Re: Sorting dates with reduced precision

Posted by tarjei <ta...@nu.no>.
On 04/22/2009 03:20 PM, Ensdorf Ken wrote:
>> Yes, but dates are fairly spesific, say 06:45 Nov. 2 , 2009. What if I
>> want to say "Sort so that withing entries for Nov. 2 , you sort by
>> relevance" for example?
>>
>
> Append "/DAY" to the date value you index, for example
>
> "1995-12-31T23:59:59Z/DAY" will yield "1995-12-31"
>
> So that all documents with the same date will then be sorted by relevance or whatever you specify as the next criteria in the "sort" parameter.
Thanks, this happens at indexing time?

kind regards,
Tarjei


>
>


RE: Sorting dates with reduced precision

Posted by Ensdorf Ken <En...@zoominfo.com>.
> Yes, but dates are fairly spesific, say 06:45 Nov. 2 , 2009. What if I
> want to say "Sort so that withing entries for Nov. 2 , you sort by
> relevance" for example?
>

Append "/DAY" to the date value you index, for example

"1995-12-31T23:59:59Z/DAY" will yield "1995-12-31"

So that all documents with the same date will then be sorted by relevance or whatever you specify as the next criteria in the "sort" parameter.




Re: Sorting dates with reduced precision

Posted by "Markus Jelsma - Buyways B.V." <ma...@buyways.nl>.
my bad, there are indeed some very nice features concerning datefields
and processing although they aren't really thorougly documented in the
wiki.


http://wiki.apache.org/solr/IndexingDates
http://lucene.apache.org/solr/api/org/apache/solr/util/DateMathParser.html

some additional information for dates within facets can be found in
http://wiki.apache.org/solr/SimpleFacetParameters#head-068dc96b0dac1cfc7264fe85528d7df5bf391acd



-  
Markus Jelsma                  Buyways B.V.             Tel. 050-3118123
Technisch Architect            Friesestraatweg 215c     Fax. 050-3118124
http://www.buyways.nl          9743 AD Groningen        KvK  01074105


On Wed, 2009-04-22 at 15:22 +0200, Markus Jelsma - Buyways B.V. wrote:

> Perhaps i don't see your problem but if you convert the dates to UNIX
> timestamps, you could use a range query to narrow your results to within
> a specific date.
> -  
> Markus Jelsma                  Buyways B.V.             Tel. 050-3118123
> Technisch Architect            Friesestraatweg 215c     Fax. 050-3118124
> http://www.buyways.nl          9743 AD Groningen        KvK  01074105
> 
> 
> On Wed, 2009-04-22 at 15:13 +0200, tarjei wrote:
> 
> > On 04/22/2009 02:57 PM, Markus Jelsma - Buyways B.V. wrote:
> > > AFAIK, according to the manual you can add multiple sort instructions:
> > > http://wiki.apache.org/solr/CommonQueryParameters#head-9f40612b42721ed9e1979a4a80d68f4f8524e9b4
> > Yes, but dates are fairly spesific, say 06:45 Nov. 2 , 2009. What if I 
> > want to say "Sort so that withing entries for Nov. 2 , you sort by 
> > relevance" for example?
> > 
> > Kind regards,
> > Tarjei
> > >
> > >
> > >
> > > -
> > > Markus Jelsma                  Buyways B.V.             Tel. 050-3118123
> > > Technisch Architect            Friesestraatweg 215c     Fax. 050-3118124
> > > http://www.buyways.nl          9743 AD Groningen        KvK  01074105
> > >
> > >
> > > On Wed, 2009-04-22 at 14:47 +0200, tarjei wrote:
> > >
> > >> Hi, I got a set of entries where I want to sort them both by the day
> > >> they were entered into solr(stored as a Solr date)  and also by another
> > >> field.
> > >>
> > >> Is this possible or do I have to create a separate field with lower
> > >> resolution?
> > >>
> > >> kind regards,
> > >> Tarjei
> > >
> > 

Re: Sorting dates with reduced precision

Posted by "Markus Jelsma - Buyways B.V." <ma...@buyways.nl>.
Perhaps i don't see your problem but if you convert the dates to UNIX
timestamps, you could use a range query to narrow your results to within
a specific date.
-  
Markus Jelsma                  Buyways B.V.             Tel. 050-3118123
Technisch Architect            Friesestraatweg 215c     Fax. 050-3118124
http://www.buyways.nl          9743 AD Groningen        KvK  01074105


On Wed, 2009-04-22 at 15:13 +0200, tarjei wrote:

> On 04/22/2009 02:57 PM, Markus Jelsma - Buyways B.V. wrote:
> > AFAIK, according to the manual you can add multiple sort instructions:
> > http://wiki.apache.org/solr/CommonQueryParameters#head-9f40612b42721ed9e1979a4a80d68f4f8524e9b4
> Yes, but dates are fairly spesific, say 06:45 Nov. 2 , 2009. What if I 
> want to say "Sort so that withing entries for Nov. 2 , you sort by 
> relevance" for example?
> 
> Kind regards,
> Tarjei
> >
> >
> >
> > -
> > Markus Jelsma                  Buyways B.V.             Tel. 050-3118123
> > Technisch Architect            Friesestraatweg 215c     Fax. 050-3118124
> > http://www.buyways.nl          9743 AD Groningen        KvK  01074105
> >
> >
> > On Wed, 2009-04-22 at 14:47 +0200, tarjei wrote:
> >
> >> Hi, I got a set of entries where I want to sort them both by the day
> >> they were entered into solr(stored as a Solr date)  and also by another
> >> field.
> >>
> >> Is this possible or do I have to create a separate field with lower
> >> resolution?
> >>
> >> kind regards,
> >> Tarjei
> >
> 

Re: Sorting dates with reduced precision

Posted by tarjei <ta...@nu.no>.
On 04/22/2009 02:57 PM, Markus Jelsma - Buyways B.V. wrote:
> AFAIK, according to the manual you can add multiple sort instructions:
> http://wiki.apache.org/solr/CommonQueryParameters#head-9f40612b42721ed9e1979a4a80d68f4f8524e9b4
Yes, but dates are fairly spesific, say 06:45 Nov. 2 , 2009. What if I 
want to say "Sort so that withing entries for Nov. 2 , you sort by 
relevance" for example?

Kind regards,
Tarjei
>
>
>
> -
> Markus Jelsma                  Buyways B.V.             Tel. 050-3118123
> Technisch Architect            Friesestraatweg 215c     Fax. 050-3118124
> http://www.buyways.nl          9743 AD Groningen        KvK  01074105
>
>
> On Wed, 2009-04-22 at 14:47 +0200, tarjei wrote:
>
>> Hi, I got a set of entries where I want to sort them both by the day
>> they were entered into solr(stored as a Solr date)  and also by another
>> field.
>>
>> Is this possible or do I have to create a separate field with lower
>> resolution?
>>
>> kind regards,
>> Tarjei
>


Re: Sorting dates with reduced precision

Posted by "Markus Jelsma - Buyways B.V." <ma...@buyways.nl>.
AFAIK, according to the manual you can add multiple sort instructions:
http://wiki.apache.org/solr/CommonQueryParameters#head-9f40612b42721ed9e1979a4a80d68f4f8524e9b4



-  
Markus Jelsma                  Buyways B.V.             Tel. 050-3118123
Technisch Architect            Friesestraatweg 215c     Fax. 050-3118124
http://www.buyways.nl          9743 AD Groningen        KvK  01074105


On Wed, 2009-04-22 at 14:47 +0200, tarjei wrote:

> Hi, I got a set of entries where I want to sort them both by the day 
> they were entered into solr(stored as a Solr date)  and also by another 
> field.
> 
> Is this possible or do I have to create a separate field with lower 
> resolution?
> 
> kind regards,
> Tarjei