lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eduardo Pierdant" <eduar...@occ.com.mx>
Subject RE: Question: searching on a NumericField, with sort and filter
Date Tue, 06 Jul 2010 18:42:57 GMT
Works perfectly now,  thx!

-----Original Message-----
From: Uwe Schindler [mailto:uwe@thetaphi.de] 
Sent: martes, 06 de julio de 2010 01:31 p.m.
To: java-user@lucene.apache.org
Subject: RE: Question: searching on a NumericField, with sort and filter

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: uwe@thetaphi.de


> -----Original Message-----
> From: Eduardo Pierdant [mailto:eduardop@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-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org



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


---------------------------------------------------------------------
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