Apache Lucene open-source search software
LUCENE-6395: MemoryIndex's TermsEnum.seekExact(long ord) was failing to set the term bytes
Michael McCandless19c70cab54c2
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex f68da29c8c2..204678536f6 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -139,6 +139,9 @@ Bug Fixesthat up to 3X (X = current index size) spare disk space may be neededto complete forceMerge(1). (Robert Muir, Shai Erera, Mike McCandless)+* LUCENE-6395: Seeking by term ordinal was failing to set the term's+ bytes in MemoryIndex (Mike McCandless)+Optimizations* LUCENE-6183, LUCENE-5647: Avoid recompressing stored fieldsdiff --git a/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java b/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.javaindex c7903f5f0fa..5e943d75ea9 100644--- a/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java+++ b/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java@@ -949,6 +949,7 @@ public class MemoryIndex {public void seekExact(long ord) {assert ord < info.terms.size();termUpto = (int) ord;+ info.terms.get(info.sortedTerms[termUpto], br);}@Overridediff --git a/lucene/memory/src/test/org/apache/lucene/index/memory/TestMemoryIndex.java b/lucene/memory/src/test/org/apache/lucene/index/memory/TestMemoryIndex.javaindex ed1bee13044..450a6837bd9 100644--- a/lucene/memory/src/test/org/apache/lucene/index/memory/TestMemoryIndex.java+++ b/lucene/memory/src/test/org/apache/lucene/index/memory/TestMemoryIndex.java@@ -17,10 +17,13 @@ package org.apache.lucene.index.memory;* limitations under the License.*/+import java.io.IOException;+import org.apache.lucene.analysis.MockAnalyzer;-import org.apache.lucene.index.LeafReader;import org.apache.lucene.index.FieldInvertState;+import org.apache.lucene.index.LeafReader;import org.apache.lucene.index.Term;+import org.apache.lucene.index.TermsEnum;import org.apache.lucene.search.IndexSearcher;import org.apache.lucene.search.MatchAllDocsQuery;import org.apache.lucene.search.TermQuery;@@ -30,8 +33,6 @@ import org.apache.lucene.util.LuceneTestCase;import org.junit.Before;import org.junit.Test;-import java.io.IOException;-import static org.hamcrest.CoreMatchers.is;import static org.hamcrest.CoreMatchers.not;import static org.junit.internal.matchers.StringContains.containsString;@@ -90,6 +91,16 @@ public class TestMemoryIndex extends LuceneTestCase {}+ public void testSeekByTermOrd() throws IOException {+ MemoryIndex mi = new MemoryIndex();+ mi.addField("field", "some terms be here", analyzer);+ IndexSearcher searcher = mi.createSearcher();+ LeafReader reader = (LeafReader) searcher.getIndexReader();+ TermsEnum terms = reader.fields().terms("field").iterator(null);+ terms.seekExact(0);+ assertEquals("be", terms.term().utf8ToString());+ }+@Testpublic void testSimilarities() throws IOException {