lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Lucene-java Wiki] Update of "SearchNumericalFields" by Peter W
Date Sun, 24 Jun 2007 03:24:11 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Lucene-java Wiki" for change notification.

The following page has been changed by Peter W:
http://wiki.apache.org/lucene-java/SearchNumericalFields

------------------------------------------------------------------------------
  == Index the relevant fields using the pad function ==
  
         doc.add(Field.Keyword("id", Number''''''Utils.pad(i)));
+ 
+ 
+ == Use a Custom RangeFilter ==
+ 
+ If you have a size field indexed using NumberTools build a custom RangeFilter to include
a subset such as 1-1500.
+ 
+ FilteredQuery fq=new FilteredQuery(query,cstm_range("size",1L,1500L)); 
+ 
+ private static Filter cstm_range(String sfld,long lmin,long lmax) 
+    { 
+    Filter lessthn_f=RangeFilter.Less(sfld,NumberTools.longToString(lmax)); 
+    Filter morethn_f=RangeFilter.More(sfld,NumberTools.longToString(lmin)); 
+    Filter[] fa=new Filter[]{lessthn_f,morethn_f}; 
+ 
+    Filter rf=new ChainedFilter(fa,ChainedFilter.AND); 
+    return rf; 
+    } 
  
  == Consider Using a Filter ==
  

Mime
View raw message