lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From parth_n <>
Subject Lucene Spatial Question: How to retrieve all results within a bounding box?
Date Sun, 08 Jun 2014 05:10:28 GMT
Hi everyone,

I am trying to retrieve all results within a given bounding box in a 2-D
space. I understand that the scoring function is based on the distance from
the center of the query. I am not looking to retrieve top-k results, but all
of them. 

I have read previous forums on this similar question, and the solutions are
either out-dated (for previous versions) or inefficient (Option 1: input k
as INTEGER.MAX_VALUE, Option 2: use a TotalHitCountCollector and get the
total number of results using getTotalHits and then pass on this number to
the top-k search). 

I am looking for all the results in the bounding box, and do not care for
the order. I do not want to waste any computation, if possible, on any
sorting needed for top-k functionality.

Question: Is there any better solution out there that I can use instead of
the above mentioned solutions?

Any reply is much appreciated. Thanks!

Snippet of the code of the above mentioned Option 1:

SpatialArgs args = new SpatialArgs(SpatialOperation.IsWithin,
ctx.makeRectangle(minX, maxX, minY, maxY));

Filter filter = strategy.makeFilter(args);
TopDocs topDocs = MatchAllDocsQuery(), filter,

ScoreDoc[] scoreDocs = topDocs.scoreDocs; 
for (ScoreDoc s : scoreDocs) 
       Document doc = searcher.doc(s.doc); 
       System.out.println(doc.get("id") + "\t" + doc.get("name")); 

View this message in context:
Sent from the Lucene - Java Users mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message