List of usage examples for org.apache.lucene.spatial.composite CompositeSpatialStrategy CompositeSpatialStrategy
public CompositeSpatialStrategy(String fieldName, RecursivePrefixTreeStrategy indexStrategy,
SerializedDVStrategy geometryStrategy)
From source file:org.apache.solr.schema.RptWithGeometrySpatialField.java
License:Apache License
@Override protected CompositeSpatialStrategy newSpatialStrategy(String fieldName) { // We use the same field name for both sub-strategies knowing there will be no conflict for these two RecursivePrefixTreeStrategy rptStrategy = rptFieldType.newSpatialStrategy(fieldName); SerializedDVStrategy geomStrategy = new CachingSerializedDVStrategy(ctx, fieldName); return new CompositeSpatialStrategy(fieldName, rptStrategy, geomStrategy); }
From source file:org.openspaces.spatial.spi.LuceneSpatialConfiguration.java
License:Open Source License
protected StrategyFactory createStrategyFactory(LuceneSpatialQueryExtensionProvider provider) { String strategyString = provider.getCustomProperty(STRATEGY, STRATEGY_DEFAULT); SupportedSpatialStrategy spatialStrategy = SupportedSpatialStrategy.byName(strategyString); switch (spatialStrategy) { case RecursivePrefixTree: { final SpatialPrefixTree geohashPrefixTree = createSpatialPrefixTree(provider, _spatialContext); String distErrPctValue = provider.getCustomProperty(DIST_ERR_PCT, DIST_ERR_PCT_DEFAULT); final double distErrPct = Double.valueOf(distErrPctValue); return new StrategyFactory(spatialStrategy) { @Override/* ww w . ja v a2s . c o m*/ public SpatialStrategy createStrategy(String fieldName) { RecursivePrefixTreeStrategy strategy = new RecursivePrefixTreeStrategy(geohashPrefixTree, fieldName); strategy.setDistErrPct(distErrPct); return strategy; } }; } case BBox: { return new StrategyFactory(spatialStrategy) { @Override public SpatialStrategy createStrategy(String fieldName) { return BBoxStrategy.newInstance(_spatialContext, fieldName); } }; } case Composite: { final SpatialPrefixTree geohashPrefixTree = createSpatialPrefixTree(provider, _spatialContext); String distErrPctValue = provider.getCustomProperty(DIST_ERR_PCT, DIST_ERR_PCT_DEFAULT); final double distErrPct = Double.valueOf(distErrPctValue); return new StrategyFactory(spatialStrategy) { @Override public SpatialStrategy createStrategy(String fieldName) { RecursivePrefixTreeStrategy recursivePrefixTreeStrategy = new RecursivePrefixTreeStrategy( geohashPrefixTree, fieldName); recursivePrefixTreeStrategy.setDistErrPct(distErrPct); SerializedDVStrategy serializedDVStrategy = new SerializedDVStrategy(_spatialContext, fieldName); return new CompositeSpatialStrategy(fieldName, recursivePrefixTreeStrategy, serializedDVStrategy); } }; } default: throw new IllegalStateException("Unsupported strategy: " + spatialStrategy); } }