Example usage for org.apache.lucene.spatial.composite CompositeSpatialStrategy CompositeSpatialStrategy

List of usage examples for org.apache.lucene.spatial.composite CompositeSpatialStrategy CompositeSpatialStrategy

Introduction

In this page you can find the example usage for org.apache.lucene.spatial.composite CompositeSpatialStrategy CompositeSpatialStrategy.

Prototype

public CompositeSpatialStrategy(String fieldName, RecursivePrefixTreeStrategy indexStrategy,
            SerializedDVStrategy geometryStrategy) 

Source Link

Usage

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);
    }
}