Sort by Date

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

Sort by Date

Mag Gam
Is it possible to sort results by date of the document?
Reply | Threaded
Open this post in threaded view
|

Re: Sort by Date

Erik Hatcher

On Aug 29, 2006, at 11:50 AM, Mag Gam wrote:
> Is it possible to sort results by date of the document?

Sure, check out the Sort class and the overloaded IndexSearcher.search
() methods that take a Sort.  You will need to index the date in a  
sortable way. DateTools provides handy methods for this purpose.

        Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Sort by Date

Mag Gam
"Index the date". Do you mean, index date, or the document date?

Could this be in a LIA book?



On 8/29/06, Erik Hatcher <[hidden email]> wrote:

>
>
> On Aug 29, 2006, at 11:50 AM, Mag Gam wrote:
> > Is it possible to sort results by date of the document?
>
> Sure, check out the Sort class and the overloaded IndexSearcher.search
> () methods that take a Sort.  You will need to index the date in a
> sortable way. DateTools provides handy methods for this purpose.
>
>        Erik
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Sort by Date

Bill Taylor-2
i gave each of my documents a special field named date and I put in a
normalized Lucene date with a precision of one day.  This date is
yyyymmdd so that it can be sorted.  having done that, however, I am
unsure how to ask Lucene to sort on that date, but I'll figure it out
in time or someone will tell me.

On Aug 29, 2006, at 3:54 PM, Mag Gam wrote:

> "Index the date". Do you mean, index date, or the document date?
>
> Could this be in a LIA book?
>
>
>
> On 8/29/06, Erik Hatcher <[hidden email]> wrote:
>>
>>
>> On Aug 29, 2006, at 11:50 AM, Mag Gam wrote:
>> > Is it possible to sort results by date of the document?
>>
>> Sure, check out the Sort class and the overloaded IndexSearcher.search
>> () methods that take a Sort.  You will need to index the date in a
>> sortable way. DateTools provides handy methods for this purpose.
>>
>>        Erik
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Sort by Date

Chris Hostetter-3

: yyyymmdd so that it can be sorted.  having done that, however, I am
: unsure how to ask Lucene to sort on that date, but I'll figure it out
: in time or someone will tell me.

you don't need to wait ... it's already been explained in this thread,
look at the Sort class and the methods in IdexSearcher which take Sort
objects.

:
: On Aug 29, 2006, at 3:54 PM, Mag Gam wrote:
:
: > "Index the date". Do you mean, index date, or the document date?
: >
: > Could this be in a LIA book?
: >
: >
: >
: > On 8/29/06, Erik Hatcher <[hidden email]> wrote:
: >>
: >>
: >> On Aug 29, 2006, at 11:50 AM, Mag Gam wrote:
: >> > Is it possible to sort results by date of the document?
: >>
: >> Sure, check out the Sort class and the overloaded IndexSearcher.search
: >> () methods that take a Sort.  You will need to index the date in a
: >> sortable way. DateTools provides handy methods for this purpose.
: >>
: >>        Erik
: >>
: >>
: >> ---------------------------------------------------------------------
: >> To unsubscribe, e-mail: [hidden email]
: >> For additional commands, e-mail: [hidden email]
: >>
: >>
:
:
: ---------------------------------------------------------------------
: To unsubscribe, e-mail: [hidden email]
: For additional commands, e-mail: [hidden email]
:



-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Sort by Date

Erik Hatcher
In reply to this post by Mag Gam

On Aug 29, 2006, at 3:54 PM, Mag Gam wrote:
> "Index the date". Do you mean, index date, or the document date?
>
> Could this be in a LIA book?


This is entirely up to you.  What gets indexed is entirely within the  
developers control.  What date do you want indexed?  I presume by  
"document date" you mean a file system document.  But I'm thinking  
more generally here - "documents" in Lucene can be pulled from thin  
air, not just from file system documents.  You are welcome to use the  
file system date.

LIA does have an example of this, which actually makes some tests  
fail if the data file dates are changed.  
TestDataDocumentHandler.java indexes .properties files via the Ant  
<index> task (in contrib/ant in Subversion), and that task indexes  
the file last modified timestamp automatically with each document.  
SortingExample.java has examples of sorting (though not by this  
datestamp, but same idea).

        Erik


>
>
>
> On 8/29/06, Erik Hatcher <[hidden email]> wrote:
>>
>>
>> On Aug 29, 2006, at 11:50 AM, Mag Gam wrote:
>> > Is it possible to sort results by date of the document?
>>
>> Sure, check out the Sort class and the overloaded  
>> IndexSearcher.search
>> () methods that take a Sort.  You will need to index the date in a
>> sortable way. DateTools provides handy methods for this purpose.
>>
>>        Erik
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]