You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lucenenet.apache.org by Bryan Rojo <Br...@elliottelectric.com> on 2018/04/13 14:09:58 UTC

3.0.3 Migration BinaryDocValues sample usage

Hi community,

Im looking at the migration guide and in regard to getting the Values from the field cache it says:
If you had code like this before:
String[] values = FieldCache.DEFAULT.getStrings(reader, field);
...
String aValue = values[docID];
you can do this instead:
DocTerms values = FieldCache.DEFAULT.getTerms(reader, field);
...
BytesRef term = new BytesRef();
String aValue = values.getTerm(docID, term).utf8ToString();

For some reason we don't have DocTerms in Lucene.Net but we do have BinaryDocValues instead.

So I need guidance as to how to implement the Get method in the BinaryDocValues class specially because I don't know what I'm supposed to do with the docID parameter

Previously I had an array of strings and I would just pass in the docId and get the string but here how do I use the BinaryDocValue? This is how I get the BinaryDocValue

        Private currentReaderValues As ReaderValues

        Public Overrides Function SetNextReader(context As AtomicReaderContext) As FieldComparer
            currentReaderValues = FieldCache.DEFAULT.GetTerms(context.AtomicReader, field, False)
            Return Me
        End Function

    Public Class ReaderValues
        Inherits BinaryDocValues

        Public Overrides Sub [Get](docID As Integer, result As BytesRef)
              'TODO How to deal with this do I just return the result.ToUtf8String()?
        End Sub
    End Class