Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Interface ITermToBytesRefAttribute

    This attribute is requested by TermsHashPerField to index the contents. This attribute can be used to customize the final byte[] encoding of terms.

    Consumers of this attribute call BytesRef up-front, and then invoke FillBytesRef() for each term. Example:

      TermToBytesRefAttribute termAtt = tokenStream.GetAttribute<TermToBytesRefAttribute>;
      BytesRef bytes = termAtt.BytesRef;
    
      while (tokenStream.IncrementToken()
      {
        // you must call termAtt.FillBytesRef() before doing something with the bytes.
        // this encodes the term value (internally it might be a char[], etc) into the bytes.
        int hashCode = termAtt.FillBytesRef();
    
        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(new BytesRef(bytes));
        }
      }
      ...
    Note

    This API is experimental and might change in incompatible ways in the next release.

    this is a very expert API, please use CharTermAttribute and its implementation of this method for UTF-8 terms.

    Inherited Members
    IAttribute.CopyTo(IAttribute)
    Namespace: Lucene.Net.Analysis.TokenAttributes
    Assembly: Lucene.Net.dll
    Syntax
    public interface ITermToBytesRefAttribute : IAttribute

    Properties

    | Improve this Doc View Source

    BytesRef

    Retrieve this attribute's BytesRef. The bytes are updated from the current term when the consumer calls FillBytesRef().

    Declaration
    BytesRef BytesRef { get; }
    Property Value
    Type Description
    BytesRef

    this IAttributes internal BytesRef.

    Methods

    | Improve this Doc View Source

    FillBytesRef()

    Updates the bytes BytesRef to contain this term's final encoding.

    Declaration
    void FillBytesRef()
    • Improve this Doc
    • View Source
    Back to top Copyright © 2021 The Apache Software Foundation, Licensed under the Apache License, Version 2.0
    Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation.
    All other marks mentioned may be trademarks or registered trademarks of their respective owners.