You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2012/09/13 17:48:11 UTC
svn commit: r1384380 - in /lucene/dev/branches/branch_4x: ./ lucene/
lucene/core/
lucene/core/src/test/org/apache/lucene/index/TestOmitPositions.java
Author: rmuir
Date: Thu Sep 13 15:48:10 2012
New Revision: 1384380
URL: http://svn.apache.org/viewvc?rev=1384380&view=rev
Log:
add test mixing up pos/no pos
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/lucene/ (props changed)
lucene/dev/branches/branch_4x/lucene/core/ (props changed)
lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestOmitPositions.java
Modified: lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestOmitPositions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestOmitPositions.java?rev=1384380&r1=1384379&r2=1384380&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestOmitPositions.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/test/org/apache/lucene/index/TestOmitPositions.java Thu Sep 13 15:48:10 2012
@@ -225,4 +225,41 @@ public class TestOmitPositions extends L
assertNoPrx(ram);
ram.close();
}
+
+ /** make sure we downgrade positions and payloads correctly */
+ public void testMixing() throws Exception {
+ // no positions
+ FieldType ft = new FieldType(TextField.TYPE_NOT_STORED);
+ ft.setIndexOptions(IndexOptions.DOCS_AND_FREQS);
+
+ Directory dir = newDirectory();
+ RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
+
+ for (int i = 0; i < 20; i++) {
+ Document doc = new Document();
+ if (i < 19 && random().nextBoolean()) {
+ for (int j = 0; j < 50; j++) {
+ doc.add(new TextField("foo", "i have positions", Field.Store.NO));
+ }
+ } else {
+ for (int j = 0; j < 50; j++) {
+ doc.add(new Field("foo", "i have no positions", ft));
+ }
+ }
+ iw.addDocument(doc);
+ iw.commit();
+ }
+
+ if (random().nextBoolean()) {
+ iw.forceMerge(1);
+ }
+
+ DirectoryReader ir = iw.getReader();
+ FieldInfos fis = MultiFields.getMergedFieldInfos(ir);
+ assertEquals(IndexOptions.DOCS_AND_FREQS, fis.fieldInfo("foo").getIndexOptions());
+ assertFalse(fis.fieldInfo("foo").hasPayloads());
+ iw.close();
+ ir.close();
+ dir.close(); // checkindex
+ }
}