lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Siraj Haider <si...@jobdiva.com>
Subject Custom Filter
Date Wed, 24 Mar 2010 18:56:58 GMT
Hello there,
I am getting exception when running queries with new getDocIdSet() in my 
customer filter.  Following is the code for my getDocIdSet() function:

/public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
     OpenBitSet bitSet = new OpenBitSet(reader.maxDoc());
     for (int i=0; i<reader.maxDoc(); i++) {
       if (reader.isDeleted(i)) continue;
       Document doc = reader.document(i);

       if (doc.getValues("ZIPLAT"+t_id)==null || 
doc.getValues("ZIPLON"+t_id)==null) continue;
       try {
         SpatialLocation teamLocation=new 
SpatialLocation(toRadians(doc.getValues("ZIPLON"+t_id)[0]), 
toRadians(doc.getValues("ZIPLAT"+t_id)[0]));
         if (location.getDistance(teamLocation) <= radius) bitSet.set(i);
       } catch (Exception e) {
         e.printStackTrace(System.out);
         continue;
       }
     }
     return bitSet;
}
/
I am searching with the following code:
/        QueryParser queryParser = new QueryParser(""   , analyzer);

         DisjunctionMaxQuery query = new DisjunctionMaxQuery(0);
         for (int i=0; i<criterias.length; i++) {
           Query subquery = queryParser.parse(criterias[i].criteria);
           ZipcodeFilter zipFilter = null;
           if (criterias[i].zipcode!=null) {
             print("ZipFilter : " + criterias[i].zipcode.zip + " within 
" + criterias[i].zipcode.radius + " miles.");
             zipFilter = new 
ZipcodeFilter(criterias[i].zipcode.latitude, 
criterias[i].zipcode.longitude, (double) criterias[i].zipcode.radius, 
teamID);
             subquery = new FilteredQuery(subquery, zipFilter);
           }
           query.add(subquery);
         }/

As you can see, I have multiple queries combined using 
DisjunctionMaxQuery.  The search runs fine if with only one query, but 
if there are multiple queries, I get an ArrayIndexOutOfBoundException.

Everything was running fine when I was using the depricated bits() 
method.  Do you think I am missing something?

thanks in advance
-siraj



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message