Search in sources :

Example 1 with FastCharArrayReader

use of org.elasticsearch.common.io.FastCharArrayReader in project elasticsearch by elastic.

the class DirectCandidateGenerator method analyze.

public static int analyze(Analyzer analyzer, BytesRef toAnalyze, String field, TokenConsumer consumer, CharsRefBuilder spare) throws IOException {
    spare.copyUTF8Bytes(toAnalyze);
    CharsRef charsRef = spare.get();
    try (TokenStream ts = analyzer.tokenStream(field, new FastCharArrayReader(charsRef.chars, charsRef.offset, charsRef.length))) {
        return analyze(ts, consumer);
    }
}
Also used : TokenStream(org.apache.lucene.analysis.TokenStream) FastCharArrayReader(org.elasticsearch.common.io.FastCharArrayReader) CharsRef(org.apache.lucene.util.CharsRef)

Aggregations

TokenStream (org.apache.lucene.analysis.TokenStream)1 CharsRef (org.apache.lucene.util.CharsRef)1 FastCharArrayReader (org.elasticsearch.common.io.FastCharArrayReader)1