lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "石玉明" <shiyuming....@gmail.com>
Subject Re: Sorting by NumericField not working
Date Sat, 26 Mar 2011 01:25:52 GMT
NumericField include int float double ... and so on. but your sort uses SortField.int .  Maybe
that is the key point. 
-- newbie of Lucene


2011-03-26 



石玉明 



发件人: Azhar Jassal 
发送时间: 2011-03-25  22:23:46 
收件人: java-user@lucene.apache.org 
抄送: 
主题: Sorting by NumericField not working 
 
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
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message