Hi.

What you probably want is `TermsEnum.postings(PostingsEnum reuse, int
flags)`, with `PostingsEnum.POSITIONS` in the flags.

I'd also recommend using the `TermsEnum` to iterate the terms instead
of using your own loop, as working with postings works better if you
do.

TX

On Fri, 9 Jul 2021 at 03:11, TK Solr <tksol...@sonic.net> wrote:
>
> Hi,
> I'm porting a piece of code that uses TermPositions of Lucene 3.3 to 8.9.
> https://lucene.apache.org/core/4_0_0/MIGRATE.html reads:
>
>   *
>
>     TermPositions is renamed to DocsAndPositionsEnum, and no longer extends 
> the
>     docs only enumerator (DocsEnum).
>
> But DocsAndPositionsEnum doesn't exist in 8.9 either. There is no mention of
> removal of DocsAndPositionsEnum in any of MIGRATE.html files.
>
> Is there a recommended way to replace TermPositions? Here is the code I am
> trying to port to give you a context:
>
> private void calculateScores() throws IOException { // initialize buffers
> FixedBitSet docPointers = new FixedBitSet(reader.maxDoc()); List<Term>
> uniqueTerms = new LinkedList<>(new LinkedHashSet<>(terms)); uniqueTermSize =
> uniqueTerms.size(); this.roughThresholdFreq = (int) (uniqueTermSize *
> ROUGH_CUTOFF); for (Iterator<Term> iter = uniqueTerms.iterator();
> iter.hasNext();) { try (TermPositions tp = reader.termPositions(iter.next())) 
> {
> while (tp.next()) { int f = scoredDocs.adjustOrPutValue(tp.doc(), 1, 1); if 
> (f >
> roughThresholdFreq) { docPointers.fastSet(tp.doc()); } } } } if
> (docPointers.cardinality() > 0) { docPointerIterator = (FixedBitSetIterator)
> docPointers.iterator(); } }
>
>
> TK
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to