The term dictionary is represented as two files:
@@ -2100,7 +2096,7 @@ document.write("Last Published: " + document.lastModified);
-
+
Frequencies
The .frq file contains the lists of documents
@@ -2228,7 +2224,7 @@ document.write("Last Published: " + document.lastModified);
entry in level-1. In the example has entry 15 on level 1 a pointer to entry 15 on level 0 and entry 31 on level 1 a pointer
to entry 31 on level 0.
-
+
Positions
The .prx file contains the lists of positions that
@@ -2298,7 +2294,7 @@ document.write("Last Published: " + document.lastModified);
Payload. If PayloadLength is not stored, then this Payload has the same
length as the Payload at the previous position.
Separate norm files are created (when adequate) for both compound and non compound segments.
-
+
Term Vectors
Term Vector support is an optional on a field by
@@ -2514,7 +2510,7 @@ document.write("Last Published: " + document.lastModified);
-
+
Deleted Documents
The .del file is
optional, and only exists when a segment contains deletions.
@@ -2578,7 +2574,7 @@ document.write("Last Published: " + document.lastModified);
-
+
Limitations
diff --git a/lucene/src/site/src/documentation/content/xdocs/fileformats.xml b/lucene/src/site/src/documentation/content/xdocs/fileformats.xml
index 02a66d22845..4525096fdfe 100644
--- a/lucene/src/site/src/documentation/content/xdocs/fileformats.xml
+++ b/lucene/src/site/src/documentation/content/xdocs/fileformats.xml
@@ -1216,8 +1216,6 @@
bit is one for fields that have term vectors stored, and zero for fields
without term vectors.
-
If the third lowest-order bit is set (0x04), term positions are stored with the term vectors.
-
If the fourth lowest-order bit is set (0x08), term offsets are stored with the term vectors.
If the fifth lowest-order bit is set (0x10), norms are omitted for the indexed field.
If the sixth lowest-order bit is set (0x20), payloads are stored for the indexed field.
If the seventh lowest-order bit is set (0x40), term frequencies and positions omitted for the indexed field.
diff --git a/lucene/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java b/lucene/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java
index c4d258685dd..ca48ff2eb42 100644
--- a/lucene/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java
+++ b/lucene/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java
@@ -296,8 +296,6 @@ public class TestConsistentFieldNumbers extends LuceneTestCase {
Field expected = getField(Integer.parseInt(fi.name));
assertEquals(expected.fieldType().indexed(), fi.isIndexed);
assertEquals(expected.fieldType().storeTermVectors(), fi.storeTermVector);
- assertEquals(expected.fieldType().storeTermVectorPositions(), fi.storePositionWithTermVector);
- assertEquals(expected.fieldType().storeTermVectorOffsets(), fi.storeOffsetWithTermVector);
}
}
diff --git a/lucene/src/test/org/apache/lucene/index/TestDocumentWriter.java b/lucene/src/test/org/apache/lucene/index/TestDocumentWriter.java
index 2df405b0640..a6bd563625d 100644
--- a/lucene/src/test/org/apache/lucene/index/TestDocumentWriter.java
+++ b/lucene/src/test/org/apache/lucene/index/TestDocumentWriter.java
@@ -94,7 +94,7 @@ public class TestDocumentWriter extends LuceneTestCase {
// test that the norms are not present in the segment if
// omitNorms is true
- for (FieldInfo fi : reader.fieldInfos()) {
+ for (FieldInfo fi : reader.getFieldInfos()) {
if (fi.isIndexed) {
assertTrue(fi.omitNorms == !reader.hasNorms(fi.name));
}
@@ -327,7 +327,7 @@ public class TestDocumentWriter extends LuceneTestCase {
_TestUtil.checkIndex(dir);
SegmentReader reader = getOnlySegmentReader(IndexReader.open(dir));
- FieldInfos fi = reader.fieldInfos();
+ FieldInfos fi = reader.getFieldInfos();
// f1
assertFalse("f1 should have no norms", reader.hasNorms("f1"));
assertEquals("omitTermFreqAndPositions field bit should not be set for f1", IndexOptions.DOCS_AND_FREQS_AND_POSITIONS, fi.fieldInfo("f1").indexOptions);
diff --git a/lucene/src/test/org/apache/lucene/index/TestDuelingCodecs.java b/lucene/src/test/org/apache/lucene/index/TestDuelingCodecs.java
index 9ba90b8fea7..358487a157f 100644
--- a/lucene/src/test/org/apache/lucene/index/TestDuelingCodecs.java
+++ b/lucene/src/test/org/apache/lucene/index/TestDuelingCodecs.java
@@ -27,7 +27,6 @@ import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.document.Document;
-import org.apache.lucene.index.IndexReader.FieldOption;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.Bits;
@@ -35,6 +34,7 @@ import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.FixedBitSet;
import org.apache.lucene.util.LineFileDocs;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.ReaderUtil;
import org.apache.lucene.util.automaton.AutomatonTestUtil;
import org.apache.lucene.util.automaton.CompiledAutomaton;
import org.apache.lucene.util.automaton.RegExp;
@@ -516,13 +516,24 @@ public class TestDuelingCodecs extends LuceneTestCase {
assertFields(leftFields, rightFields, rarely());
}
}
+
+ private static Set getDVFields(IndexReader reader) {
+ Set fields = new HashSet();
+ for(FieldInfo fi : ReaderUtil.getMergedFieldInfos(reader)) {
+ if (fi.hasDocValues()) {
+ fields.add(fi.name);
+ }
+ }
+
+ return fields;
+ }
/**
* checks that docvalues across all fields are equivalent
*/
public void assertDocValues(IndexReader leftReader, IndexReader rightReader) throws Exception {
- Set leftValues = new HashSet(leftReader.getFieldNames(FieldOption.DOC_VALUES));
- Set rightValues = new HashSet(rightReader.getFieldNames(FieldOption.DOC_VALUES));
+ Set leftValues = getDVFields(leftReader);
+ Set rightValues = getDVFields(rightReader);
assertEquals(info, leftValues, rightValues);
for (String field : leftValues) {
diff --git a/lucene/src/test/org/apache/lucene/index/TestFieldInfos.java b/lucene/src/test/org/apache/lucene/index/TestFieldInfos.java
index ff05b5310bb..a73625dc60a 100644
--- a/lucene/src/test/org/apache/lucene/index/TestFieldInfos.java
+++ b/lucene/src/test/org/apache/lucene/index/TestFieldInfos.java
@@ -133,21 +133,14 @@ public class TestFieldInfos extends LuceneTestCase {
}
try {
readOnly.addOrUpdate("bogus", random.nextBoolean(), random.nextBoolean(),
- random.nextBoolean(), random.nextBoolean());
+ random.nextBoolean());
fail("instance should be read only");
} catch (IllegalStateException e) {
// expected
}
try {
readOnly.addOrUpdate("bogus", random.nextBoolean(), random.nextBoolean(),
- random.nextBoolean(), random.nextBoolean(), random.nextBoolean());
- fail("instance should be read only");
- } catch (IllegalStateException e) {
- // expected
- }
- try {
- readOnly.addOrUpdate("bogus", random.nextBoolean(), random.nextBoolean(),
- random.nextBoolean(), random.nextBoolean(), random.nextBoolean(),
+ random.nextBoolean(),
random.nextBoolean(), random.nextBoolean() ? IndexOptions.DOCS_ONLY : IndexOptions.DOCS_AND_FREQS_AND_POSITIONS, null);
fail("instance should be read only");
} catch (IllegalStateException e) {
diff --git a/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java b/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java
index ae7fedf84b5..cd1a48dec5f 100644
--- a/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java
+++ b/lucene/src/test/org/apache/lucene/index/TestFieldsReader.java
@@ -80,24 +80,18 @@ public class TestFieldsReader extends LuceneTestCase {
assertTrue(field != null);
assertTrue(field.fieldType().storeTermVectors());
- assertTrue(field.fieldType().storeTermVectorOffsets());
- assertTrue(field.fieldType().storeTermVectorPositions());
assertFalse(field.fieldType().omitNorms());
assertTrue(field.fieldType().indexOptions() == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
field = (Field) doc.getField(DocHelper.TEXT_FIELD_3_KEY);
assertTrue(field != null);
assertFalse(field.fieldType().storeTermVectors());
- assertFalse(field.fieldType().storeTermVectorOffsets());
- assertFalse(field.fieldType().storeTermVectorPositions());
assertTrue(field.fieldType().omitNorms());
assertTrue(field.fieldType().indexOptions() == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
field = (Field) doc.getField(DocHelper.NO_TF_KEY);
assertTrue(field != null);
assertFalse(field.fieldType().storeTermVectors());
- assertFalse(field.fieldType().storeTermVectorOffsets());
- assertFalse(field.fieldType().storeTermVectorPositions());
assertFalse(field.fieldType().omitNorms());
assertTrue(field.fieldType().indexOptions() == IndexOptions.DOCS_ONLY);
diff --git a/lucene/src/test/org/apache/lucene/index/TestFilterIndexReader.java b/lucene/src/test/org/apache/lucene/index/TestFilterIndexReader.java
index bf728b2e0f7..4122ec0206b 100644
--- a/lucene/src/test/org/apache/lucene/index/TestFilterIndexReader.java
+++ b/lucene/src/test/org/apache/lucene/index/TestFilterIndexReader.java
@@ -18,20 +18,20 @@ package org.apache.lucene.index;
*/
-import org.apache.lucene.util.LuceneTestCase;
-
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.analysis.MockAnalyzer;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.TextField;
-import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.Bits;
-
import java.io.IOException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.HashSet;
+import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.TextField;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.Bits;
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.ReaderUtil;
+
public class TestFilterIndexReader extends LuceneTestCase {
private static class TestReader extends FilterIndexReader {
@@ -121,6 +121,11 @@ public class TestFilterIndexReader extends LuceneTestCase {
public Fields fields() throws IOException {
return new TestFields(super.fields());
}
+
+ @Override
+ public FieldInfos getFieldInfos() {
+ return ReaderUtil.getMergedFieldInfos(in);
+ }
}
/**
diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexReader.java b/lucene/src/test/org/apache/lucene/index/TestIndexReader.java
index 6a75f7c1307..f1796271097 100644
--- a/lucene/src/test/org/apache/lucene/index/TestIndexReader.java
+++ b/lucene/src/test/org/apache/lucene/index/TestIndexReader.java
@@ -36,7 +36,6 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
-import org.apache.lucene.index.IndexReader.FieldOption;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.FieldCache;
@@ -46,6 +45,7 @@ import org.apache.lucene.store.NoSuchDirectoryException;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.ReaderUtil;
import org.apache.lucene.util._TestUtil;
import org.junit.Assume;
@@ -102,11 +102,11 @@ public class TestIndexReader extends LuceneTestCase {
writer.close();
// set up reader
IndexReader reader = IndexReader.open(d);
- Collection fieldNames = reader.getFieldNames(IndexReader.FieldOption.ALL);
- assertTrue(fieldNames.contains("keyword"));
- assertTrue(fieldNames.contains("text"));
- assertTrue(fieldNames.contains("unindexed"));
- assertTrue(fieldNames.contains("unstored"));
+ FieldInfos fieldInfos = ReaderUtil.getMergedFieldInfos(reader);
+ assertNotNull(fieldInfos.fieldInfo("keyword"));
+ assertNotNull(fieldInfos.fieldInfo("text"));
+ assertNotNull(fieldInfos.fieldInfo("unindexed"));
+ assertNotNull(fieldInfos.fieldInfo("unstored"));
reader.close();
// add more documents
writer = new IndexWriter(
@@ -160,61 +160,66 @@ public class TestIndexReader extends LuceneTestCase {
}
writer.close();
+
// verify fields again
reader = IndexReader.open(d);
- fieldNames = reader.getFieldNames(IndexReader.FieldOption.ALL);
- assertEquals(13, fieldNames.size()); // the following fields
- assertTrue(fieldNames.contains("keyword"));
- assertTrue(fieldNames.contains("text"));
- assertTrue(fieldNames.contains("unindexed"));
- assertTrue(fieldNames.contains("unstored"));
- assertTrue(fieldNames.contains("keyword2"));
- assertTrue(fieldNames.contains("text2"));
- assertTrue(fieldNames.contains("unindexed2"));
- assertTrue(fieldNames.contains("unstored2"));
- assertTrue(fieldNames.contains("tvnot"));
- assertTrue(fieldNames.contains("termvector"));
- assertTrue(fieldNames.contains("tvposition"));
- assertTrue(fieldNames.contains("tvoffset"));
- assertTrue(fieldNames.contains("tvpositionoffset"));
+ fieldInfos = ReaderUtil.getMergedFieldInfos(reader);
+
+ Collection allFieldNames = new HashSet();
+ Collection indexedFieldNames = new HashSet();
+ Collection notIndexedFieldNames = new HashSet();
+ Collection tvFieldNames = new HashSet();
+
+ for(FieldInfo fieldInfo : fieldInfos) {
+ final String name = fieldInfo.name;
+ allFieldNames.add(name);
+ if (fieldInfo.isIndexed) {
+ indexedFieldNames.add(name);
+ } else {
+ notIndexedFieldNames.add(name);
+ }
+ if (fieldInfo.storeTermVector) {
+ tvFieldNames.add(name);
+ }
+ }
+
+ assertTrue(allFieldNames.contains("keyword"));
+ assertTrue(allFieldNames.contains("text"));
+ assertTrue(allFieldNames.contains("unindexed"));
+ assertTrue(allFieldNames.contains("unstored"));
+ assertTrue(allFieldNames.contains("keyword2"));
+ assertTrue(allFieldNames.contains("text2"));
+ assertTrue(allFieldNames.contains("unindexed2"));
+ assertTrue(allFieldNames.contains("unstored2"));
+ assertTrue(allFieldNames.contains("tvnot"));
+ assertTrue(allFieldNames.contains("termvector"));
+ assertTrue(allFieldNames.contains("tvposition"));
+ assertTrue(allFieldNames.contains("tvoffset"));
+ assertTrue(allFieldNames.contains("tvpositionoffset"));
// verify that only indexed fields were returned
- fieldNames = reader.getFieldNames(IndexReader.FieldOption.INDEXED);
- assertEquals(11, fieldNames.size()); // 6 original + the 5 termvector fields
- assertTrue(fieldNames.contains("keyword"));
- assertTrue(fieldNames.contains("text"));
- assertTrue(fieldNames.contains("unstored"));
- assertTrue(fieldNames.contains("keyword2"));
- assertTrue(fieldNames.contains("text2"));
- assertTrue(fieldNames.contains("unstored2"));
- assertTrue(fieldNames.contains("tvnot"));
- assertTrue(fieldNames.contains("termvector"));
- assertTrue(fieldNames.contains("tvposition"));
- assertTrue(fieldNames.contains("tvoffset"));
- assertTrue(fieldNames.contains("tvpositionoffset"));
+ assertEquals(11, indexedFieldNames.size()); // 6 original + the 5 termvector fields
+ assertTrue(indexedFieldNames.contains("keyword"));
+ assertTrue(indexedFieldNames.contains("text"));
+ assertTrue(indexedFieldNames.contains("unstored"));
+ assertTrue(indexedFieldNames.contains("keyword2"));
+ assertTrue(indexedFieldNames.contains("text2"));
+ assertTrue(indexedFieldNames.contains("unstored2"));
+ assertTrue(indexedFieldNames.contains("tvnot"));
+ assertTrue(indexedFieldNames.contains("termvector"));
+ assertTrue(indexedFieldNames.contains("tvposition"));
+ assertTrue(indexedFieldNames.contains("tvoffset"));
+ assertTrue(indexedFieldNames.contains("tvpositionoffset"));
// verify that only unindexed fields were returned
- fieldNames = reader.getFieldNames(IndexReader.FieldOption.UNINDEXED);
- assertEquals(2, fieldNames.size()); // the following fields
- assertTrue(fieldNames.contains("unindexed"));
- assertTrue(fieldNames.contains("unindexed2"));
+ assertEquals(2, notIndexedFieldNames.size()); // the following fields
+ assertTrue(notIndexedFieldNames.contains("unindexed"));
+ assertTrue(notIndexedFieldNames.contains("unindexed2"));
// verify index term vector fields
- fieldNames = reader.getFieldNames(IndexReader.FieldOption.TERMVECTOR);
- assertEquals(1, fieldNames.size()); // 1 field has term vector only
- assertTrue(fieldNames.contains("termvector"));
-
- fieldNames = reader.getFieldNames(IndexReader.FieldOption.TERMVECTOR_WITH_POSITION);
- assertEquals(1, fieldNames.size()); // 4 fields are indexed with term vectors
- assertTrue(fieldNames.contains("tvposition"));
-
- fieldNames = reader.getFieldNames(IndexReader.FieldOption.TERMVECTOR_WITH_OFFSET);
- assertEquals(1, fieldNames.size()); // 4 fields are indexed with term vectors
- assertTrue(fieldNames.contains("tvoffset"));
-
- fieldNames = reader.getFieldNames(IndexReader.FieldOption.TERMVECTOR_WITH_POSITION_OFFSET);
- assertEquals(1, fieldNames.size()); // 4 fields are indexed with term vectors
- assertTrue(fieldNames.contains("tvpositionoffset"));
+ assertEquals(tvFieldNames.toString(), 4, tvFieldNames.size()); // 4 field has term vector only
+ assertTrue(tvFieldNames.contains("termvector"));
+
reader.close();
d.close();
}
@@ -519,19 +524,19 @@ public class TestIndexReader extends LuceneTestCase {
}
// check field names
- Collection fields1 = index1.getFieldNames(FieldOption.ALL);
- Collection fields2 = index1.getFieldNames(FieldOption.ALL);
- assertEquals("IndexReaders have different numbers of fields.", fields1.size(), fields2.size());
- Iterator it1 = fields1.iterator();
- Iterator it2 = fields1.iterator();
- while (it1.hasNext()) {
- assertEquals("Different field names.", it1.next(), it2.next());
+ FieldInfos fieldInfos1 = ReaderUtil.getMergedFieldInfos(index1);
+ FieldInfos fieldInfos2 = ReaderUtil.getMergedFieldInfos(index2);
+ assertEquals("IndexReaders have different numbers of fields.", fieldInfos1.size(), fieldInfos2.size());
+ final int numFields = fieldInfos1.size();
+ for(int fieldID=0;fieldID fieldNames = pr.getFieldNames(IndexReader.FieldOption.ALL);
- assertEquals(4, fieldNames.size());
- assertTrue(fieldNames.contains("f1"));
- assertTrue(fieldNames.contains("f2"));
- assertTrue(fieldNames.contains("f3"));
- assertTrue(fieldNames.contains("f4"));
+ FieldInfos fieldInfos = pr.getFieldInfos();
+ assertEquals(4, fieldInfos.size());
+ assertNotNull(fieldInfos.fieldInfo("f1"));
+ assertNotNull(fieldInfos.fieldInfo("f2"));
+ assertNotNull(fieldInfos.fieldInfo("f3"));
+ assertNotNull(fieldInfos.fieldInfo("f4"));
pr.close();
dir1.close();
dir2.close();
diff --git a/lucene/src/test/org/apache/lucene/index/TestPayloads.java b/lucene/src/test/org/apache/lucene/index/TestPayloads.java
index e4eb66b4209..20506d456c6 100644
--- a/lucene/src/test/org/apache/lucene/index/TestPayloads.java
+++ b/lucene/src/test/org/apache/lucene/index/TestPayloads.java
@@ -112,7 +112,7 @@ public class TestPayloads extends LuceneTestCase {
writer.close();
SegmentReader reader = getOnlySegmentReader(IndexReader.open(ram));
- FieldInfos fi = reader.fieldInfos();
+ FieldInfos fi = reader.getFieldInfos();
assertFalse("Payload field bit should not be set.", fi.fieldInfo("f1").storePayloads);
assertTrue("Payload field bit should be set.", fi.fieldInfo("f2").storePayloads);
assertFalse("Payload field bit should not be set.", fi.fieldInfo("f3").storePayloads);
@@ -139,7 +139,7 @@ public class TestPayloads extends LuceneTestCase {
writer.close();
reader = getOnlySegmentReader(IndexReader.open(ram));
- fi = reader.fieldInfos();
+ fi = reader.getFieldInfos();
assertFalse("Payload field bit should not be set.", fi.fieldInfo("f1").storePayloads);
assertTrue("Payload field bit should be set.", fi.fieldInfo("f2").storePayloads);
assertTrue("Payload field bit should be set.", fi.fieldInfo("f3").storePayloads);
diff --git a/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java b/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java
index 30a036e1070..e5b6eb84114 100644
--- a/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java
+++ b/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java
@@ -18,7 +18,6 @@ package org.apache.lucene.index;
*/
import java.io.IOException;
-import java.util.Collection;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.codecs.Codec;
@@ -30,6 +29,7 @@ import org.apache.lucene.util.InfoStream;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
+
public class TestSegmentMerger extends LuceneTestCase {
//The variables for the new merged segment
private Directory mergedDir;
@@ -107,10 +107,15 @@ public class TestSegmentMerger extends LuceneTestCase {
assertTrue(termDocs != null);
assertTrue(termDocs.nextDoc() != DocsEnum.NO_MORE_DOCS);
- Collection stored = mergedReader.getFieldNames(IndexReader.FieldOption.INDEXED_WITH_TERMVECTOR);
- assertTrue(stored != null);
+ int tvCount = 0;
+ for(FieldInfo fieldInfo : mergedReader.getFieldInfos()) {
+ if (fieldInfo.storeTermVector) {
+ tvCount++;
+ }
+ }
+
//System.out.println("stored size: " + stored.size());
- assertTrue("We do not have 3 fields that were indexed with term vector",stored.size() == 3);
+ assertEquals("We do not have 3 fields that were indexed with term vector", 3, tvCount);
Terms vector = mergedReader.getTermVectors(0).terms(DocHelper.TEXT_FIELD_2_KEY);
assertNotNull(vector);
diff --git a/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java b/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java
index d7e9fa25c45..8935aec9679 100644
--- a/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java
+++ b/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java
@@ -19,7 +19,7 @@ package org.apache.lucene.index;
import java.io.IOException;
import java.util.Collection;
-import java.util.Iterator;
+import java.util.HashSet;
import java.util.List;
import org.apache.lucene.document.Document;
@@ -74,33 +74,42 @@ public class TestSegmentReader extends LuceneTestCase {
}
public void testGetFieldNameVariations() {
- Collection result = reader.getFieldNames(IndexReader.FieldOption.ALL);
- assertTrue(result != null);
- assertTrue(result.size() == DocHelper.all.size());
- for (Iterator iter = result.iterator(); iter.hasNext();) {
- String s = iter.next();
- //System.out.println("Name: " + s);
+ Collection allFieldNames = new HashSet();
+ Collection indexedFieldNames = new HashSet();
+ Collection notIndexedFieldNames = new HashSet();
+ Collection tvFieldNames = new HashSet();
+ Collection noTVFieldNames = new HashSet();
+
+ for(FieldInfo fieldInfo : reader.getFieldInfos()) {
+ final String name = fieldInfo.name;
+ allFieldNames.add(name);
+ if (fieldInfo.isIndexed) {
+ indexedFieldNames.add(name);
+ } else {
+ notIndexedFieldNames.add(name);
+ }
+ if (fieldInfo.storeTermVector) {
+ tvFieldNames.add(name);
+ } else if (fieldInfo.isIndexed) {
+ noTVFieldNames.add(name);
+ }
+ }
+
+ assertTrue(allFieldNames.size() == DocHelper.all.size());
+ for (String s : allFieldNames) {
assertTrue(DocHelper.nameValues.containsKey(s) == true || s.equals(""));
}
- result = reader.getFieldNames(IndexReader.FieldOption.INDEXED);
- assertTrue(result != null);
- assertTrue(result.size() == DocHelper.indexed.size());
- for (Iterator iter = result.iterator(); iter.hasNext();) {
- String s = iter.next();
+
+ assertTrue(indexedFieldNames.size() == DocHelper.indexed.size());
+ for (String s : indexedFieldNames) {
assertTrue(DocHelper.indexed.containsKey(s) == true || s.equals(""));
}
- result = reader.getFieldNames(IndexReader.FieldOption.UNINDEXED);
- assertTrue(result != null);
- assertTrue(result.size() == DocHelper.unindexed.size());
+ assertTrue(notIndexedFieldNames.size() == DocHelper.unindexed.size());
//Get all indexed fields that are storing term vectors
- result = reader.getFieldNames(IndexReader.FieldOption.INDEXED_WITH_TERMVECTOR);
- assertTrue(result != null);
- assertTrue(result.size() == DocHelper.termvector.size());
-
- result = reader.getFieldNames(IndexReader.FieldOption.INDEXED_NO_TERMVECTOR);
- assertTrue(result != null);
- assertTrue(result.size() == DocHelper.notermvector.size());
+ assertTrue(tvFieldNames.size() == DocHelper.termvector.size());
+
+ assertTrue(noTVFieldNames.size() == DocHelper.notermvector.size());
}
public void testTerms() throws IOException {
diff --git a/modules/analysis/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java b/modules/analysis/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java
index e01980d0fab..f8e3abcb2da 100644
--- a/modules/analysis/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java
+++ b/modules/analysis/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java
@@ -16,22 +16,23 @@ package org.apache.lucene.analysis.query;
* limitations under the License.
*/
-import org.apache.lucene.analysis.AnalyzerWrapper;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.index.TermsEnum;
-import org.apache.lucene.index.Terms;
-import org.apache.lucene.index.MultiFields;
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.core.StopFilter;
-import org.apache.lucene.util.CharsRef;
-import org.apache.lucene.util.UnicodeUtil;
-import org.apache.lucene.util.Version;
-import org.apache.lucene.util.BytesRef;
-
import java.io.IOException;
import java.util.*;
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.AnalyzerWrapper;
+import org.apache.lucene.analysis.core.StopFilter;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.MultiFields;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.index.Terms;
+import org.apache.lucene.index.TermsEnum;
+import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.CharsRef;
+import org.apache.lucene.util.ReaderUtil;
+import org.apache.lucene.util.UnicodeUtil;
+import org.apache.lucene.util.Version;
+
/**
* An {@link Analyzer} used primarily at query time to wrap another analyzer and provide a layer of protection
* which prevents very common words from being passed into queries.
@@ -84,7 +85,7 @@ public final class QueryAutoStopWordAnalyzer extends AnalyzerWrapper {
Analyzer delegate,
IndexReader indexReader,
int maxDocFreq) throws IOException {
- this(matchVersion, delegate, indexReader, indexReader.getFieldNames(IndexReader.FieldOption.INDEXED), maxDocFreq);
+ this(matchVersion, delegate, indexReader, ReaderUtil.getIndexedFields(indexReader), maxDocFreq);
}
/**
@@ -104,7 +105,7 @@ public final class QueryAutoStopWordAnalyzer extends AnalyzerWrapper {
Analyzer delegate,
IndexReader indexReader,
float maxPercentDocs) throws IOException {
- this(matchVersion, delegate, indexReader, indexReader.getFieldNames(IndexReader.FieldOption.INDEXED), maxPercentDocs);
+ this(matchVersion, delegate, indexReader, ReaderUtil.getIndexedFields(indexReader), maxPercentDocs);
}
/**
diff --git a/modules/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java b/modules/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java
index bea471ae2e4..c9287c59be2 100644
--- a/modules/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java
+++ b/modules/queries/src/java/org/apache/lucene/queries/mlt/MoreLikeThis.java
@@ -34,6 +34,7 @@ import org.apache.lucene.search.similarities.TFIDFSimilarity;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.CharsRef;
import org.apache.lucene.util.PriorityQueue;
+import org.apache.lucene.util.ReaderUtil;
import org.apache.lucene.util.UnicodeUtil;
@@ -569,7 +570,7 @@ public final class MoreLikeThis {
public Query like(int docNum) throws IOException {
if (fieldNames == null) {
// gather list of valid fields from lucene
- Collection fields = ir.getFieldNames(IndexReader.FieldOption.INDEXED);
+ Collection fields = ReaderUtil.getIndexedFields(ir);
fieldNames = fields.toArray(new String[fields.size()]);
}
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
index 740074a19b9..44c8e8fadfd 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
@@ -27,13 +27,11 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.*;
import org.apache.lucene.index.FieldInfo.IndexOptions;
-import static org.apache.lucene.index.FieldInfo.IndexOptions.DOCS_ONLY;
-import static org.apache.lucene.index.FieldInfo.IndexOptions.DOCS_AND_FREQS;
-
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.CharsRef;
import org.apache.lucene.util.PriorityQueue;
+import org.apache.lucene.util.ReaderUtil;
import org.apache.lucene.util.UnicodeUtil;
import org.apache.solr.analysis.CharFilterFactory;
import org.apache.solr.analysis.TokenFilterFactory;
@@ -55,7 +53,9 @@ import org.apache.solr.schema.SchemaField;
import org.apache.solr.search.SolrIndexSearcher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.lucene.index.DocsEnum;
+
+import static org.apache.lucene.index.FieldInfo.IndexOptions.DOCS_AND_FREQS;
+import static org.apache.lucene.index.FieldInfo.IndexOptions.DOCS_ONLY;
/**
* This handler exposes the internal lucene index. It is inspired by and
@@ -289,11 +289,15 @@ public class LukeRequestHandler extends RequestHandlerBase
IndexReader reader = searcher.getIndexReader();
IndexSchema schema = searcher.getSchema();
+ Set fieldNames = new TreeSet();
+ for(FieldInfo fieldInfo : ReaderUtil.getMergedFieldInfos(reader)) {
+ fieldNames.add(fieldInfo.name);
+ }
+
// Walk the term enum and keep a priority queue for each map in our set
SimpleOrderedMap