javanna commented on code in PR #16985:
URL: https://github.com/apache/lucene/pull/16985#discussion_r4483012291
##########
lucene/highlighter/src/java/org/apache/lucene/search/highlight/package-info.java:
##########
@@ -48,7 +48,7 @@
* }
* //Term vector
* text = doc.get("tv");
- * tokenStream = TokenSources.getAnyTokenStream(searcher.getIndexReader(),
hits.scoreDocs[i].doc, "tv", analyzer);
+ * tokenStream = TokenSources.getTokenStream("tv",
searcher.getIndexReader().termVectors().get(id), text, analyzer, -1);
Review Comment:
there seems to be a couple of existing issues in here, up above, perhaps
worth fixing in a followup: `search.doc(id)` is gone? I think we also load term
vectors twice for the same doc, which we should fix?
##########
lucene/MIGRATE.md:
##########
@@ -28,6 +28,15 @@ with `VisitedSet.create(expectedVisitedNodes, graphSize)`.
## Migration from Lucene 10.x to Lucene 11.0
+### Deprecated TokenSources methods have been removed (GITHUB#16985)
+
+The highlighter's `TokenSources` class now only has `getTokenStream(String
field, Fields tvFields,
+String text, Analyzer analyzer, int maxStartOffset)` and
`getTermVectorTokenStreamOrNull(String
+field, Fields tvFields, int maxStartOffset)`. The `getAnyTokenStream` and
+`getTokenStreamWithOffsets` methods and all other `getTokenStream` overloads
are removed.
+Load the document's term vectors once with `reader.termVectors().get(docId)`,
get the field value
+from the stored fields, and pass both to `getTokenStream`. Use `-1` as
`maxStartOffset` for no limit.
Review Comment:
it could be good to have a code snippet here, like we have in other migrate
notes (which I forgot to suggest in the latest deprecation removals I merged).
Something like:
```
// before
TokenStream ts = TokenSources.getAnyTokenStream(reader, docId, field,
analyzer);
// after
Fields tvFields = reader.termVectors().get(docId);
String text = reader.storedFields().document(docId).get(field);
TokenStream ts = TokenSources.getTokenStream(field, tvFields, text,
analyzer, -1);
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]