lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Otis Gospodnetic <otis_gospodne...@yahoo.com>
Subject Re: Help for sorting
Date Mon, 03 Jan 2005 16:16:53 GMT
Hello,

--- mahaveer jain <jainmahaveer23@yahoo.com> wrote:

> I am looking out to implement sorting in my lucene application. This
> is what my code look like. 
> 
> I am using StandardAnalyzer() analyzer. 
> 
> Query query = QueryParser.parse(keyword, "contents", analyzer); 
> 
> Sort sortCol = new Sort(new SortField("date"));
> 
> // date is one of the field I have indexed.
> 
> Hits hits = searcher.search(query, sortCol);
> 
> for (int start = 0; start < hits.length(); start ++) { 
> Document doc = hits.doc(start); 
> 
> // get all the data required.
> } 
> 
> I get this error : 
> 
> no terms in field sdate - cannot determine sort type 

Is it possible that your 'date' field is empty in some documents you
indexed?  If so, you should specify your sort field type explicitly. 
Look at the Javadoc for SortField class.

> Can any let me know where I am wrong ? Also what is the default
> sorting in lucene ? 

Default sorting is by rank/score.

> Also can some one explain what exactly is the score ? Is it something
> to do with ranking ? Do somebody have a link to a good lucene
> tutorial ? 

There are links to a few Lucene articles on Lucene's Wiki.  There is
also a link to the Lucene book (Lucene in Action) on the same page. 
Another good source of information about how to use the Lucene API are
Lucene's unit tests.

Otis


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message