You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by "Luis Fco. Ramriez Daza Glez" <lu...@yahoo.com.mx> on 2010/01/21 19:31:54 UTC

How to get the "greater" term/word in a single-word numeric field

Hi all

 

I have an index some field that each one has a single integer number.

I want to get the greatest value of this field in all my documents.

What is the best way to get it for both, numeric value stored as string (without padding zeros) and numeric value stored as number?

 

Since I don’t have a better choice I had been getting ALL documents and sorting them by this field to get the greatest and the lowest:

[pseudo code]

Hits = SELECT * FROM MyIndex ORDER BY MyFiled DESC

Value = Hits.doc(0).get(“MyField”)

 

But what I realy want is something like the SQL equiv of:

SELECT MAX(MyField) FROM MyIndex

Or

SELECT MIN(MyField) FROM MyIndex

 

Kind regards

Luis