lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yonik Seeley" <ysee...@gmail.com>
Subject Re: Lucene Document order not being maintained?
Date Wed, 05 Apr 2006 23:35:00 GMT
OK, the following patch seems to work for me!
You might want to try it out on your larger test Dan.

The first part probably isn't necessary (the base=start instead of
start+1), but the second part is.

-Yonik
http://incubator.apache.org/solr Solr, The Open Source Lucene Search Server



Index: org/apache/lucene/index/IndexWriter.java
===================================================================
--- org/apache/lucene/index/IndexWriter.java    (revision 391084)
+++ org/apache/lucene/index/IndexWriter.java    (working copy)
@@ -569,7 +569,7 @@

     // merge newly added segments in log(n) passes
     while (segmentInfos.size() > start+mergeFactor) {
-      for (int base = start+1; base < segmentInfos.size(); base++) {
+      for (int base = start; base < segmentInfos.size(); base++) {
         int end = Math.min(segmentInfos.size(), base+mergeFactor);
         if (end-base > 1)
           mergeSegments(base, end);
@@ -710,9 +710,9 @@
       infoStream.println(" into "+mergedName+" ("+mergedDocCount+" docs)");
     }

-    for (int i = end-1; i >= minSegment; i--)     // remove old infos & add new

+    for (int i = end-1; i > minSegment; i--)     // remove old infos & add new
       segmentInfos.remove(i);
-    segmentInfos.addElement(new SegmentInfo(mergedName, mergedDocCount,
+    segmentInfos.set(minSegment, new SegmentInfo(mergedName, mergedDocCount,
                                             directory));

     // close readers before we attempt to delete now-obsolete segments

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


Mime
View raw message