sort on a searchable field

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

sort on a searchable field

moraleslos
From what I understand about Lucene, one can only sort on a field that is indexed but not tokenized (and hence not searchable).  I have content that can be searched by keyword and also a date string, e.g. text:Lucene AND date:[2007-01-01 TO 2007-01-10]

Since my date is searchable, I need to index + tokenize it.  I would like to somehow return the hits sorted by date.  Is there a workaround for this using Lucene?  Thanks in advance!

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

Re: sort on a searchable field

Yonik Seeley-2
On 1/10/07, moraleslos <[hidden email]> wrote:
> From what I understand about Lucene, one can only sort on a field that is
> indexed but not tokenized (and hence not searchable).  I have content that
> can be searched by keyword and also a date string, e.g. text:Lucene AND
> date:[2007-01-01 TO 2007-01-10]
>
> Since my date is searchable, I need to index + tokenize it.  I would like to
> somehow return the hits sorted by date.  Is there a workaround for this
> using Lucene?  Thanks in advance!

The restriction is really that there shouldn't be more than one token
for that field per document.

-Yonik
http://incubator.apache.org/solr Solr, the open-source Lucene search server

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

Reply | Threaded
Open this post in threaded view
|

Re: sort on a searchable field

Erick Erickson
In reply to this post by moraleslos
I'm pretty sure you can search UN_TOKENIZED fields, just be sure the
analyzers you use for querying don't break your query input up.... The
javadoc implies so (for the Sort class...)

**************
he fields used to determine sort order must be carefully chosen. Documents
must contain a single term in such a field, and the value of the term should
indicate the document's relative position in a given sort order. The field
must be indexed, but should not be tokenized, and does not need to be stored
(unless you happen to want it back with the rest of your document data). In
other words:

document.add (new Field ("byNumber", Integer.toString(x), Field.Store.NO,
Field.Index.UN_TOKENIZED));

*******************


Best
Erick


On 1/10/07, moraleslos <[hidden email]> wrote:

>
>
> From what I understand about Lucene, one can only sort on a field that is
> indexed but not tokenized (and hence not searchable).  I have content that
> can be searched by keyword and also a date string, e.g. text:Lucene AND
> date:[2007-01-01 TO 2007-01-10]
>
> Since my date is searchable, I need to index + tokenize it.  I would like
> to
> somehow return the hits sorted by date.  Is there a workaround for this
> using Lucene?  Thanks in advance!
>
> -los
> --
> View this message in context:
> http://www.nabble.com/sort-on-a-searchable-field-tf2954961.html#a8265729
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>