[ 
https://issues.apache.org/jira/browse/LUCENE-1872?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12749102#action_12749102
 ] 

Uwe Schindler commented on LUCENE-1872:
---------------------------------------

bq. I'm confused on why it's the "largest" value? EG if I add 4, 17, 10 as a 
NumericField "x" on my doc, when I then try to sort, wouldn't 10 "win" since it 
was added last to the document?

Because of the uninverter. It iterates over all terms, starting from the lowest 
one in the field. When he comes to term 4, it would add it to the field cache 
at the document's position. The same with 10 and then 17. Because the TermEnum 
lists 17 at last, it would win:

{code}
long[] retArray = null;
TermDocs termDocs = reader.termDocs();
TermEnum termEnum = reader.terms (new Term(field));
try {
  do {
    Term term = termEnum.term();
    if (term==null || term.field() != field) break;
    long termval = parser.parseLong(term.text());
    if (retArray == null) // late init
      retArray = new long[reader.maxDoc()];
    termDocs.seek (termEnum);
    while (termDocs.next()) {
      retArray[termDocs.doc()] = termval;
    }
  } while (termEnum.next());
} catch (StopFillCacheException stop) {
} finally {
  termDocs.close();
  termEnum.close();
}
if (retArray == null) // no values
  retArray = new long[reader.maxDoc()];
{code}

> Improve javadocs for Numeric*
> -----------------------------
>
>                 Key: LUCENE-1872
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1872
>             Project: Lucene - Java
>          Issue Type: Improvement
>            Reporter: Michael McCandless
>            Assignee: Michael McCandless
>            Priority: Minor
>             Fix For: 2.9
>
>
> I'm working on improving Numeric* javadocs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-dev-h...@lucene.apache.org

Reply via email to