You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Siraj Haider <si...@jobdiva.com> on 2010/03/24 19:56:58 UTC
Custom Filter
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
Re: Custom Filter
Posted by Siraj Haider <si...@jobdiva.com>.
I figured this one out... it was due to a mistake in my code... sorry
for trouble.
-siraj
On 3/25/2010 5:48 AM, Ian Lea wrote:
> Could this maybe have something to do with per-segment readers, as
> mentioned in recent message from Daniel?
>
> Posting lucene version and the full stack trace dump is always a good idea.
>
>
> --
> Ian.
>
>
> On Wed, Mar 24, 2010 at 6:56 PM, Siraj Haider<si...@jobdiva.com> wrote:
>
>> 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
>>
>>
>>
>>
> ---------------------------------------------------------------------
> 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
Re: Custom Filter
Posted by Ian Lea <ia...@gmail.com>.
Could this maybe have something to do with per-segment readers, as
mentioned in recent message from Daniel?
Posting lucene version and the full stack trace dump is always a good idea.
--
Ian.
On Wed, Mar 24, 2010 at 6:56 PM, Siraj Haider <si...@jobdiva.com> wrote:
> 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
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org