You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by GitBox <gi...@apache.org> on 2021/04/29 13:47:24 UTC

[GitHub] [lucenenet] jregnier commented on issue #477: Fetching a docvalue from the index

jregnier commented on issue #477:
URL: https://github.com/apache/lucenenet/issues/477#issuecomment-829252365


   Hello again, So I think I'm getting closer lol, seems like the way to go is to create a custom ICollector. Below is what I have so far. Am I on the right track so far?
   
   `    public class MyCollector : ICollector
       {
           private readonly OpenBitSet _bits;
           private int _docBase;
           private BinaryDocValues _docValues;
           private HashSet<string> _values;
   
           public MyCollector(OpenBitSet bits)
           {
               _bits = bits ?? throw new ArgumentNullException(nameof(bits));
               _values= new HashSet<string>();
           }
   
           public bool AcceptsDocsOutOfOrder => true;
   
           public void Collect(int doc)
           {
               _bits.Set(doc + _docBase);
   
               if (_docValues== null)
               {
                   return;
               }
   
               var byteRef = new BytesRef();
               _docValues.Get(doc, byteRef);
               _values.Add(byteRef.Utf8ToString());
           }
   
           public void SetNextReader(AtomicReaderContext context)
           {
               _docValues = context.AtomicReader.GetBinaryDocValues("the_value");
               _docBase = context.DocBase;
           }
   
           public void SetScorer(Scorer scorer)
           {
               // We don't care about the score.
           }
       }`
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org