Java Code Examples for org.apache.lucene.spatial.prefix.PrefixTreeStrategy

The following examples show how to use org.apache.lucene.spatial.prefix.PrefixTreeStrategy. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * This analyzer is not actually used for indexing.  It is implemented here
 * so that the analysis UI will show reasonable tokens.
 */
@Override
public Analyzer getIndexAnalyzer() {
  return new Analyzer() {
    @Override
    protected TokenStreamComponents createComponents(String fieldName) {
      PrefixTreeStrategy s = newSpatialStrategy(fieldName == null ? getTypeName() : fieldName);
      PrefixTreeStrategy.ShapeTokenStream ts = s.tokenStream();
      return new TokenStreamComponents(r -> {
        try {
          ts.setShape(parseShape(IOUtils.toString(r)));
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }, ts);
    }
  };
}
 
Example 2
Source Project: Elasticsearch   Source File: GeoShapeFieldMapper.java    License: Apache License 2.0 5 votes vote down vote up
public PrefixTreeStrategy resolveStrategy(String strategyName) {
    if (SpatialStrategy.RECURSIVE.getStrategyName().equals(strategyName)) {
        return recursiveStrategy;
    }
    if (SpatialStrategy.TERM.getStrategyName().equals(strategyName)) {
        return termStrategy;
    }
    throw new IllegalArgumentException("Unknown prefix tree strategy [" + strategyName + "]");
}
 
Example 3
Source Project: lucene-solr   Source File: FacetHeatmap.java    License: Apache License 2.0 5 votes vote down vote up
FacetHeatmap(Map<String, Object> argsMap, PrefixTreeStrategy strategy, Shape boundsShape, int gridLevel, int maxCells, String format) {
  this.argsMap = argsMap;
  this.strategy = strategy;
  this.boundsShape = boundsShape;
  this.gridLevel = gridLevel;
  this.maxCells = maxCells;
  this.format = format;
}
 
Example 4
Source Project: crate   Source File: GeoShapeFieldMapper.java    License: Apache License 2.0 5 votes vote down vote up
public PrefixTreeStrategy resolveStrategy(String strategyName) {
    if (SpatialStrategy.RECURSIVE.getStrategyName().equals(strategyName)) {
        return recursiveStrategy;
    }
    if (SpatialStrategy.TERM.getStrategyName().equals(strategyName)) {
        return termStrategy;
    }
    throw new IllegalArgumentException("Unknown prefix tree strategy [" + strategyName + "]");
}
 
Example 5
Source Project: Elasticsearch   Source File: GeoShapeFieldMapper.java    License: Apache License 2.0 4 votes vote down vote up
public PrefixTreeStrategy defaultStrategy() {
    return this.defaultStrategy;
}
 
Example 6
Source Project: crate   Source File: GeoShapeFieldMapper.java    License: Apache License 2.0 4 votes vote down vote up
public PrefixTreeStrategy defaultStrategy() {
    return this.defaultStrategy;
}
 
Example 7
Source Project: crate   Source File: GeoShapeFieldMapper.java    License: Apache License 2.0 4 votes vote down vote up
public PrefixTreeStrategy resolveStrategy(SpatialStrategy strategy) {
    return resolveStrategy(strategy.getStrategyName());
}