Hi Eduardo, For sorting or a NumericRangeQuery, the field must be *indexed*. Storing has no effect at all, it's only needed, if you want to show the value in search results. That is important for *any* type of field (not only NumericField).
Uwe ----- Uwe Schindler H.-H.-Meier-Allee 63, D-28213 Bremen http://www.thetaphi.de eMail: u...@thetaphi.de > -----Original Message----- > From: Eduardo Pierdant [mailto:eduar...@occ.com.mx] > Sent: Tuesday, July 06, 2010 7:49 PM > To: java-user@lucene.apache.org > Subject: Question: searching on a NumericField, with sort and filter > > > Hi all. > > > I've been dealing with a small problem when searching and trying to sort and > filter on a NumericField using Lucene 2.9.2; the result never comes back as > expected. Here are some snippets of my code, so you might take a look and > reference me or help me out to solve this problem. > > > At document creation, I add the field like this: > doc.add(new NumericField("PuntosJobSense", Field.Store.YES, > false).setIntValue(Integer.parseInt(puntosJS))); > > When searching, I use a sort field and a Filter: > > SortField sf = new SortField("PuntosPatrocinadas", SortField.INT, > true); > Sort sortOrder = new Sort(sf); > Filter nf = NumericRangeFilter.newIntRange("PuntosPatrocinadas", > 0, Integer.MAX_VALUE, true, true); > hits = searcher.search(query, nf, MAX_DOC_SEARCH, > sortOrder).scoreDocs; > > the only "query" parameter that I'm passing so far is "date modified" that > uses the date the document was added to the index. If I don't use this search > and simply search without filter nor sorting, everything is ok. > > Hope someone can help me out. > Eduardo > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org