mirror of https://github.com/apache/lucene.git
LUCENE-2308: DocumentStoredFieldVisitor was failing to set indexed bit in returned field
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1162431 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2ed4c9afc0
commit
5a4458aea6
|
@ -76,11 +76,12 @@ public class DocumentStoredFieldVisitor extends StoredFieldVisitor {
|
||||||
if (accept(fieldInfo)) {
|
if (accept(fieldInfo)) {
|
||||||
final byte[] b = new byte[numUTF8Bytes];
|
final byte[] b = new byte[numUTF8Bytes];
|
||||||
in.readBytes(b, 0, b.length);
|
in.readBytes(b, 0, b.length);
|
||||||
FieldType ft = new FieldType(TextField.TYPE_STORED);
|
final FieldType ft = new FieldType(TextField.TYPE_STORED);
|
||||||
ft.setStoreTermVectors(fieldInfo.storeTermVector);
|
ft.setStoreTermVectors(fieldInfo.storeTermVector);
|
||||||
ft.setStoreTermVectorPositions(fieldInfo.storePositionWithTermVector);
|
ft.setStoreTermVectorPositions(fieldInfo.storePositionWithTermVector);
|
||||||
ft.setStoreTermVectorOffsets(fieldInfo.storeOffsetWithTermVector);
|
ft.setStoreTermVectorOffsets(fieldInfo.storeOffsetWithTermVector);
|
||||||
ft.setStoreTermVectors(fieldInfo.storeTermVector);
|
ft.setStoreTermVectors(fieldInfo.storeTermVector);
|
||||||
|
ft.setIndexed(fieldInfo.isIndexed);
|
||||||
ft.setOmitNorms(fieldInfo.omitNorms);
|
ft.setOmitNorms(fieldInfo.omitNorms);
|
||||||
ft.setIndexOptions(fieldInfo.indexOptions);
|
ft.setIndexOptions(fieldInfo.indexOptions);
|
||||||
doc.add(new Field(fieldInfo.name,
|
doc.add(new Field(fieldInfo.name,
|
||||||
|
|
|
@ -24,7 +24,9 @@ import java.util.*;
|
||||||
import org.apache.lucene.analysis.MockAnalyzer;
|
import org.apache.lucene.analysis.MockAnalyzer;
|
||||||
import org.apache.lucene.document.Document;
|
import org.apache.lucene.document.Document;
|
||||||
import org.apache.lucene.document.Field;
|
import org.apache.lucene.document.Field;
|
||||||
|
import org.apache.lucene.document.FieldType;
|
||||||
import org.apache.lucene.document.NumericField;
|
import org.apache.lucene.document.NumericField;
|
||||||
|
import org.apache.lucene.document.StringField;
|
||||||
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
import org.apache.lucene.index.FieldInfo.IndexOptions;
|
||||||
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
|
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
|
||||||
import org.apache.lucene.search.FieldCache;
|
import org.apache.lucene.search.FieldCache;
|
||||||
|
@ -295,4 +297,20 @@ public class TestFieldsReader extends LuceneTestCase {
|
||||||
dir.close();
|
dir.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testIndexedBit() throws Exception {
|
||||||
|
Directory dir = newDirectory();
|
||||||
|
RandomIndexWriter w = new RandomIndexWriter(random, dir);
|
||||||
|
Document doc = new Document();
|
||||||
|
FieldType onlyStored = new FieldType();
|
||||||
|
onlyStored.setStored(true);
|
||||||
|
doc.add(new Field("field", onlyStored, "value"));
|
||||||
|
doc.add(new Field("field2", StringField.TYPE_STORED, "value"));
|
||||||
|
w.addDocument(doc);
|
||||||
|
IndexReader r = w.getReader();
|
||||||
|
w.close();
|
||||||
|
assertFalse(r.document(0).getField("field").indexed());
|
||||||
|
assertTrue(r.document(0).getField("field2").indexed());
|
||||||
|
r.close();
|
||||||
|
dir.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue