diff --git a/lucene/core/src/java/org/apache/lucene/search/DocIdSetIterator.java b/lucene/core/src/java/org/apache/lucene/search/DocIdSetIterator.java index 3a77fc746e7..900fc1e8811 100644 --- a/lucene/core/src/java/org/apache/lucene/search/DocIdSetIterator.java +++ b/lucene/core/src/java/org/apache/lucene/search/DocIdSetIterator.java @@ -60,13 +60,17 @@ public abstract class DocIdSetIterator { */ public abstract int nextDoc() throws IOException; - /** - * Advances to the first beyond (see NOTE below) the current whose document - * number is greater than or equal to target. Returns the current - * document number or {@link #NO_MORE_DOCS} if there are no more docs in the - * set. + /** + * Advances to the first beyond the current whose document number is greater + * than or equal to target, and returns the document number itself. + * Exhausts the iterator and returns {@link #NO_MORE_DOCS} if target + * is greater than the highest document number in the set. *

- * Behaves as if written: + * The behavior of this method is undefined when called with + * target ≤ current, or after the iterator has exhausted. + * Both cases may result in unpredicted behavior. + *

+ * When target > current it behaves as if written: * *

    * int advance(int target) {
@@ -79,18 +83,12 @@ public abstract class DocIdSetIterator {
    * 
    * Some implementations are considerably more efficient than that.
    * 

- * NOTE: when target ≤ current implementations may opt - * not to advance beyond their current {@link #docID()}. - *

* NOTE: this method may be called with {@link #NO_MORE_DOCS} for * efficiency by some Scorers. If your implementation cannot efficiently * determine that it should exhaust, it is recommended that you check for that * value in each call to this method. *

- * NOTE: after the iterator has exhausted you should not call this - * method, as it may result in unpredicted behavior. - *

- * + * * @since 2.9 */ public abstract int advance(int target) throws IOException;