public interface TermToBytesRefAttribute extends Attribute
Consumers of this attribute call getBytesRef() for each term. Example:
final TermToBytesRefAttribute termAtt = tokenStream.getAttribute(TermToBytesRefAttribute.class);
while (tokenStream.incrementToken() {
final BytesRef bytes = termAtt.getBytesRef();
if (isInteresting(bytes)) {
// because the bytes are reused by the attribute (like CharTermAttribute's char[] buffer),
// you should make a copy if you need persistent access to the bytes, otherwise they will
// be rewritten across calls to incrementToken()
doSomethingWith(BytesRef.deepCopyOf(bytes));
}
}
...
CharTermAttribute and its implementation for UTF-8 terms; to
index binary terms, use BytesTermAttribute and its implementation.| Modifier and Type | Method and Description |
|---|---|
BytesRef |
getBytesRef()
Retrieve this attribute's BytesRef.
|
BytesRef getBytesRef()
Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.