Search in sources :

Example 1 with PathHierarchyTokenizerFactory

use of org.apache.lucene.analysis.path.PathHierarchyTokenizerFactory in project jackrabbit-oak by apache.

the class IndexDefinition method createAnalyzer.

//~---------------------------------------------------< Analyzer >
private Analyzer createAnalyzer() {
    Analyzer result;
    Analyzer defaultAnalyzer = LuceneIndexConstants.ANALYZER;
    if (analyzers.containsKey(LuceneIndexConstants.ANL_DEFAULT)) {
        defaultAnalyzer = analyzers.get(LuceneIndexConstants.ANL_DEFAULT);
    }
    if (!evaluatePathRestrictions()) {
        result = defaultAnalyzer;
    } else {
        Map<String, Analyzer> analyzerMap = ImmutableMap.<String, Analyzer>builder().put(FieldNames.ANCESTORS, new TokenizerChain(new PathHierarchyTokenizerFactory(Collections.<String, String>emptyMap()))).build();
        result = new PerFieldAnalyzerWrapper(defaultAnalyzer, analyzerMap);
    }
    //In case of negative value no limits would be applied
    if (maxFieldLength < 0) {
        return result;
    }
    return new LimitTokenCountAnalyzer(result, maxFieldLength);
}
Also used : LimitTokenCountAnalyzer(org.apache.lucene.analysis.miscellaneous.LimitTokenCountAnalyzer) PathHierarchyTokenizerFactory(org.apache.lucene.analysis.path.PathHierarchyTokenizerFactory) TokenizerChain(org.apache.jackrabbit.oak.plugins.index.lucene.util.TokenizerChain) LimitTokenCountAnalyzer(org.apache.lucene.analysis.miscellaneous.LimitTokenCountAnalyzer) Analyzer(org.apache.lucene.analysis.Analyzer) PerFieldAnalyzerWrapper(org.apache.lucene.analysis.miscellaneous.PerFieldAnalyzerWrapper)

Aggregations

TokenizerChain (org.apache.jackrabbit.oak.plugins.index.lucene.util.TokenizerChain)1 Analyzer (org.apache.lucene.analysis.Analyzer)1 LimitTokenCountAnalyzer (org.apache.lucene.analysis.miscellaneous.LimitTokenCountAnalyzer)1 PerFieldAnalyzerWrapper (org.apache.lucene.analysis.miscellaneous.PerFieldAnalyzerWrapper)1 PathHierarchyTokenizerFactory (org.apache.lucene.analysis.path.PathHierarchyTokenizerFactory)1