Example usage for org.apache.lucene.analysis.shingle ShingleFilter DEFAULT_MAX_SHINGLE_SIZE

List of usage examples for org.apache.lucene.analysis.shingle ShingleFilter DEFAULT_MAX_SHINGLE_SIZE

Introduction

In this page you can find the example usage for org.apache.lucene.analysis.shingle ShingleFilter DEFAULT_MAX_SHINGLE_SIZE.

Prototype

int DEFAULT_MAX_SHINGLE_SIZE

To view the source code for org.apache.lucene.analysis.shingle ShingleFilter DEFAULT_MAX_SHINGLE_SIZE.

Click Source Link

Document

default maximum shingle size is 2.

Usage

From source file:org.apache.solr.analysis.ShingleFilterFactory.java

License:Apache License

@Override
public void init(Map<String, String> args) {
    super.init(args);
    maxShingleSize = getInt("maxShingleSize", ShingleFilter.DEFAULT_MAX_SHINGLE_SIZE);
    if (maxShingleSize < 2) {
        throw new SolrException(ErrorCode.SERVER_ERROR,
                "Invalid maxShingleSize (" + maxShingleSize + ") - must be at least 2");
    }// ww  w  . j a  v a2 s . c o  m
    minShingleSize = getInt("minShingleSize", ShingleFilter.DEFAULT_MIN_SHINGLE_SIZE);
    if (minShingleSize < 2) {
        throw new SolrException(ErrorCode.SERVER_ERROR,
                "Invalid minShingleSize (" + minShingleSize + ") - must be at least 2");
    }
    if (minShingleSize > maxShingleSize) {
        throw new SolrException(ErrorCode.SERVER_ERROR, "Invalid minShingleSize (" + minShingleSize
                + ") - must be no greater than maxShingleSize (" + maxShingleSize + ")");
    }
    outputUnigrams = getBoolean("outputUnigrams", true);
    outputUnigramsIfNoShingles = getBoolean("outputUnigramsIfNoShingles", false);
    tokenSeparator = args.containsKey("tokenSeparator") ? args.get("tokenSeparator")
            : ShingleFilter.TOKEN_SEPARATOR;
}

From source file:org.elasticsearch.index.analysis.ShingleTokenFilterFactory.java

License:Apache License

@Inject
public ShingleTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name,
        @Assisted Settings settings) {/* ww w.  ja  v a2  s  .co  m*/
    super(index, indexSettings, name, settings);
    Integer maxShingleSize = settings.getAsInt("max_shingle_size", ShingleFilter.DEFAULT_MAX_SHINGLE_SIZE);
    Integer minShingleSize = settings.getAsInt("min_shingle_size", ShingleFilter.DEFAULT_MIN_SHINGLE_SIZE);
    Boolean outputUnigrams = settings.getAsBoolean("output_unigrams", true);
    Boolean outputUnigramsIfNoShingles = settings.getAsBoolean("output_unigrams_if_no_shingles", false);
    String tokenSeparator = settings.get("token_separator", ShingleFilter.DEFAULT_TOKEN_SEPARATOR);
    String fillerToken = settings.get("filler_token", ShingleFilter.DEFAULT_FILLER_TOKEN);
    factory = new Factory("shingle", minShingleSize, maxShingleSize, outputUnigrams, outputUnigramsIfNoShingles,
            tokenSeparator, fillerToken);
}