use of org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy in project lucene-solr by apache.
the class SpatialRecursivePrefixTreeFieldType method newPrefixTreeStrategy.
@Override
protected RecursivePrefixTreeStrategy newPrefixTreeStrategy(String fieldName) {
RecursivePrefixTreeStrategy strategy = new RecursivePrefixTreeStrategy(grid, fieldName);
if (prefixGridScanLevel != null)
strategy.setPrefixGridScanLevel(prefixGridScanLevel);
if (grid instanceof PackedQuadPrefixTree) {
// This grid has a (usually) better prune leafy branch implementation
((PackedQuadPrefixTree) grid).setPruneLeafyBranches(true);
strategy.setPruneLeafyBranches(false);
}
return strategy;
}
use of org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy in project lucene-solr by apache.
the class SpatialExample method init.
protected void init() {
//Typical geospatial context
// These can also be constructed from SpatialContextFactory
this.ctx = SpatialContext.GEO;
//results in sub-meter precision for geohash
int maxLevels = 11;
//TODO demo lookup by detail distance
// This can also be constructed from SpatialPrefixTreeFactory
SpatialPrefixTree grid = new GeohashPrefixTree(ctx, maxLevels);
this.strategy = new RecursivePrefixTreeStrategy(grid, "myGeoField");
this.directory = new RAMDirectory();
}
use of org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy in project lucene-solr by apache.
the class DistanceStrategyTest method parameters.
@ParametersFactory(argumentFormatting = "strategy=%s")
public static Iterable<Object[]> parameters() {
List<Object[]> ctorArgs = new ArrayList<>();
SpatialContext ctx = SpatialContext.GEO;
SpatialPrefixTree grid;
SpatialStrategy strategy;
grid = new QuadPrefixTree(ctx, 25);
strategy = new RecursivePrefixTreeStrategy(grid, "recursive_quad");
ctorArgs.add(new Object[] { strategy.getFieldName(), strategy });
grid = new GeohashPrefixTree(ctx, 12);
strategy = new TermQueryPrefixTreeStrategy(grid, "termquery_geohash");
ctorArgs.add(new Object[] { strategy.getFieldName(), strategy });
grid = new PackedQuadPrefixTree(ctx, 25);
strategy = new RecursivePrefixTreeStrategy(grid, "recursive_packedquad");
ctorArgs.add(new Object[] { strategy.getFieldName(), strategy });
strategy = PointVectorStrategy.newInstance(ctx, "pointvector");
ctorArgs.add(new Object[] { strategy.getFieldName(), strategy });
// Can't test this without un-inverting since PVS legacy config didn't have docValues.
// However, note that Solr's tests use UninvertingReader and thus test this.
// strategy = PointVectorStrategy.newLegacyInstance(ctx, "pointvector_legacy");
// ctorArgs.add(new Object[]{strategy.getFieldName(), strategy});
strategy = BBoxStrategy.newInstance(ctx, "bbox");
ctorArgs.add(new Object[] { strategy.getFieldName(), strategy });
strategy = new SerializedDVStrategy(ctx, "serialized");
ctorArgs.add(new Object[] { strategy.getFieldName(), strategy });
return ctorArgs;
}
use of org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy in project lucene-solr by apache.
the class SpatialDocMaker method makeRPTStrategy.
protected RecursivePrefixTreeStrategy makeRPTStrategy(String spatialField, Config config, Map<String, String> configMap, SpatialContext ctx) {
//A factory for the prefix tree grid
SpatialPrefixTree grid = SpatialPrefixTreeFactory.makeSPT(configMap, null, ctx);
RecursivePrefixTreeStrategy strategy = new RecursivePrefixTreeStrategy(grid, spatialField);
strategy.setPointsOnly(config.get("spatial.docPointsOnly", false));
final boolean pruneLeafyBranches = config.get("spatial.pruneLeafyBranches", true);
if (grid instanceof PackedQuadPrefixTree) {
((PackedQuadPrefixTree) grid).setPruneLeafyBranches(pruneLeafyBranches);
//always leave it to packed grid, even though it isn't the same
strategy.setPruneLeafyBranches(false);
} else {
strategy.setPruneLeafyBranches(pruneLeafyBranches);
}
int prefixGridScanLevel = config.get("query.spatial.prefixGridScanLevel", -4);
if (prefixGridScanLevel < 0)
prefixGridScanLevel = grid.getMaxLevels() + prefixGridScanLevel;
strategy.setPrefixGridScanLevel(prefixGridScanLevel);
//doc & query; a default
double distErrPct = config.get("spatial.distErrPct", .025);
strategy.setDistErrPct(distErrPct);
return strategy;
}
use of org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy in project ddf by codice.
the class TestGeoNamesQueryLuceneIndex method setUp.
@Before
public void setUp() throws IOException {
directoryIndex = spy(new GeoNamesQueryLuceneDirectoryIndex());
directoryIndex.setIndexLocation(null);
final SpatialPrefixTree grid = new GeohashPrefixTree(SPATIAL_CONTEXT, GeoNamesLuceneConstants.GEOHASH_LEVELS);
strategy = new RecursivePrefixTreeStrategy(grid, GeoNamesLuceneConstants.GEO_FIELD);
initializeIndex();
doReturn(directory).when(directoryIndex).openDirectory();
}
Aggregations