lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Lea <ian....@gmail.com>
Subject Re: Sorting by NumericField not working
Date Fri, 25 Mar 2011 14:33:54 GMT
>From the javadoc for SortField: Fields must be indexed in order to
sort by them.

>From the javadoc for NumericField:

public NumericField(String name,
                    int precisionStep,
                    Field.Store store,
                    boolean index)

--
Ian.

P.S. Read the javadocs!


On Fri, Mar 25, 2011 at 2:23 PM, Azhar Jassal <az.jassal@gmail.com> wrote:
> Hi,
>
> I'm trying to sort results by a NumericField but the results do not sort
> (still appear in default score order). The NumericField was indexed using
> the code below:
>
> NumericField field = new NumericField(name,
> NumericUtils.PRECISION_STEP_DEFAULT, Field.Store.YES, false);
> field.setIntValue(value);
> document.add(field);
>
> The searcher uses the following code to attempt to sort at search:
>
> Sort sortBySize = new Sort(new SortField[] { new SortField("subj",
> SortField.INT) });
> TopFieldDocs topDocs = searcher.search(tq, null, limit, sortBySize);
>
> Any ideas please? Is this the right method of sorting using a NumericField?
>
> Az
>

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


Mime
View raw message