Example usage for org.apache.lucene.analysis.core WhitespaceAnalyzer getOffsetGap

List of usage examples for org.apache.lucene.analysis.core WhitespaceAnalyzer getOffsetGap

Introduction

In this page you can find the example usage for org.apache.lucene.analysis.core WhitespaceAnalyzer getOffsetGap.

Prototype

public int getOffsetGap(String fieldName) 

Source Link

Document

Just like #getPositionIncrementGap , except for Token offsets instead.

Usage

From source file:org.gridkit.coherence.search.lucene.TokenStreamCheck.java

License:Apache License

@Test
public void analyze() throws IOException {

    WhitespaceAnalyzer wa = new WhitespaceAnalyzer(Version.LUCENE_42);
    wa.getOffsetGap("xxx");
    TokenStream ts = wa.tokenStream("test", new StringReader("red black tree"));
    ts.reset();//from   w  w w . ja va  2 s .  c om
    ts.incrementToken();
    ts.getAttribute(CharTermAttribute.class).buffer();

    CapturedTokenStream cts = new CapturedTokenStream(ts);
    cts.reset();
    cts.incrementToken();
    cts.getAttribute(CharTermAttribute.class).buffer();
}