From 933bac2435e57e124967f215e94e040dce5f66ba Mon Sep 17 00:00:00 2001 From: Doug Cutting Date: Fri, 20 Sep 2002 17:25:13 +0000 Subject: [PATCH] Patched to fix a bug when empty indexes or segments exist. git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@149859 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/lucene/index/SegmentsReader.java | 6 +++++- src/java/org/apache/lucene/search/MultiSearcher.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/lucene/index/SegmentsReader.java b/src/java/org/apache/lucene/index/SegmentsReader.java index a1b63e71414..289cd629362 100644 --- a/src/java/org/apache/lucene/index/SegmentsReader.java +++ b/src/java/org/apache/lucene/index/SegmentsReader.java @@ -125,8 +125,12 @@ final class SegmentsReader extends IndexReader hi = mid - 1; else if (n > midValue) lo = mid + 1; - else + else { // found a match + while (mid+1 < readers.length && starts[mid+1] == midValue) { + mid++; // scan to last match + } return mid; + } } return hi; } diff --git a/src/java/org/apache/lucene/search/MultiSearcher.java b/src/java/org/apache/lucene/search/MultiSearcher.java index c7e8f2e0583..ddc845236a8 100644 --- a/src/java/org/apache/lucene/search/MultiSearcher.java +++ b/src/java/org/apache/lucene/search/MultiSearcher.java @@ -116,8 +116,12 @@ public class MultiSearcher extends Searcher implements Searchable { hi = mid - 1; else if (n > midValue) lo = mid + 1; - else + else { // found a match + while (mid+1 < searchables.length && starts[mid+1] == midValue) { + mid++; // scan to last match + } return mid; + } } return hi; }