Hi André,

In this case you simply sort on the field. This may suffice:

Searcher searcher = new IndexSearcher(directory);

Sort = new Sort(new SortField("another_field", SortField.AUTO, false));

Hits hits = searcher.search(query,sort);


You can limit the number of hits (e.g. to 5), but I won't get into that here.


Beyond SortField.AUTO, take a look at the SortField class to see specific field 
types - the most interesting being SortField.CUSTOM.


-----Original Message-----
From: André Maldonado [mailto:andre.maldon...@gmail.com] 
Sent: Friday, October 30, 2009 1:46 PM
To: lucene-net-user@incubator.apache.org
Subject: Re: Simple question

Hi Franklin.

Wich query I use for this search (variable: query)? I don't want any query,
I just want the TOP 5 documents ordered by a field.

Thank's

"Então aproximaram-se os que estavam no barco, e adoraram-no, dizendo: És
verdadeiramente o Filho de Deus." (Mateus 14:33)


On Fri, Oct 30, 2009 at 15:03, Franklin Simmons <fsimm...@sccmediaserver.com
> wrote:

> You can sort a search by multiple fields.  I think you could try something
> like this:
>
> Searcher searcher = new IndexSearcher(directory);
> Sort = new Sort(new SortField[] { SortField.FIELD_SCORE, new
> SortField("another_field") };
> Hits hits = searcher.search(query,sort);
>
>
> -----Original Message-----
> From: André Maldonado [mailto:andre.maldon...@gmail.com]
> Sent: Friday, October 30, 2009 12:57 PM
> To: lucene-net-user@incubator.apache.org
> Subject: Simple question
>
> Hi.
>
> This can be a simple question, but I can't figure out the solution.
>
> I need to search my index in something like "SELECT TOP 5 ... ORDER BY
> another_field". But this is an empty query because I want to search in all
> documents.
>
> How can I do it?
>
> Thank's
>

Reply via email to