The realization idea is according to 文斌 to provide. The concept of the perimeter search implemented in this article is only a trivial part of the engine being implemented as a 文斌. Thank you for 文斌 's guidance here!
For a space based index, the first example of this idea in the sixth chapter of the Lucene in action is to illustrate how to use Lucene to find space information. The need to solve the problem is "what Mexican food restaurant are nearest to me?" The solution is to use the Lucene filter function. And my idea is this, is to provide a filter to the Lucene index file filtering.
Filtering as a mechanism to reduce the scope of Lucene search, the possible results are limited to one of all documents in a child set. An attribute that can be used to implement a search based on permissions and to search again in search results.
When it comes to concrete implementations, the key is that the filter itself is based on the logo bit setting.
The filter part implements the following code:
/** *//**
*
* @author Lang
* @date 2007-12-19
* @email lanfanss@126.com
* @desc provided with a certain space position to provide a Filter
* @since
*
*/
public class Spatialfilter extends filter {
int lo;
int LA;
int scope;
Quadtree Quadtree;
Public spatialfilter (int lo, int la, int scope, Quadtree quadtree) {
super ();
This.lo = lo;
this.la = LA;
This.scope = scope;
This.quadtree = Quadtree;
}
@Override
public bitset bits (Indexreader reader) throws IOException {
Final bitset bits = New Bitset (Reader.maxdoc ());
//Set All documents cannot be retrieved
Bits.set (0, Bits.size ()-1, false);
Judge scope, if unreasonable, using the default 500 m
if (scope <= 0) {
scope = +;
//currently using a simple rectangular box as a range search
list<string> ids = quadtree.query (New Envelope (The new coordinate (LO
-Scope, La-scope), new coordinate (lo + scope, la + scope));
for (String id:ids) {
//rectangle-scoped dots are
Bits.set (integer.valueof (IDs) that can be searched by Lucene). Intvalue (), TR UE);
}
return bits;
}