Github user jpountz commented on a diff in the pull request: https://github.com/apache/lucene-solr/pull/345#discussion_r180494440 --- Diff: lucene/core/src/java/org/apache/lucene/search/Weight.java --- @@ -69,6 +69,24 @@ protected Weight(Query query) { */ public abstract void extractTerms(Set<Term> terms); + /** + * Returns {@link Matches} for a specific document, or {@code null} if the document + * does not match the parent query + * + * A query match that contains no position information (for example, a Point or + * DocValues query) will return {@link Matches#MATCH_WITH_NO_TERMS} + * + * @param context the reader's context to create the {@link Matches} for + * @param doc the document's id relative to the given context's reader + */ + public Matches matches(LeafReaderContext context, int doc) throws IOException { + Scorer scorer = scorer(context); + if (scorer == null || scorer.iterator().advance(doc) != doc) { --- End diff -- we might want to check the two-phase iterator instead if there is one so that `iterator().advance()` doesn't potentially visit millions of candidates before finding one that actually matches. See for instance ConstantScoreWeight.explain.
--- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org