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 2011/08/30 01:13:23 UTC
svn commit: r1163047 [8/15] - in /lucene/dev/branches/flexscoring: ./
dev-tools/idea/lucene/contrib/ lucene/ lucene/contrib/
lucene/contrib/demo/src/java/org/apache/lucene/demo/
lucene/contrib/demo/src/java/org/apache/lucene/demo/xmlparser/ lucene/cont...
Modified: lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReader.java?rev=1163047&r1=1163046&r2=1163047&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReader.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReader.java Mon Aug 29 23:13:10 2011
@@ -31,27 +31,22 @@ import java.util.Set;
import java.util.SortedSet;
import org.junit.Assume;
import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.document.BinaryField;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
-import org.apache.lucene.document.FieldSelector;
-import org.apache.lucene.document.Fieldable;
-import org.apache.lucene.document.SetBasedFieldSelector;
+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.codecs.CodecProvider;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.FieldCache;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.ScoreDoc;
-import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.similarities.DefaultSimilarity;
-import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.LockObtainFailedException;
-import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.store.NoSuchDirectoryException;
-import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.store.LockReleaseFailedException;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util._TestUtil;
@@ -154,10 +149,14 @@ public class TestIndexReader extends Luc
);
Document doc = new Document();
- doc.add(new Field("keyword","test1", Field.Store.YES, Field.Index.NOT_ANALYZED));
- doc.add(new Field("text","test1", Field.Store.YES, Field.Index.ANALYZED));
- doc.add(new Field("unindexed","test1", Field.Store.YES, Field.Index.NO));
- doc.add(new Field("unstored","test1", Field.Store.NO, Field.Index.ANALYZED));
+
+ FieldType customType3 = new FieldType();
+ customType3.setStored(true);
+
+ doc.add(new Field("keyword",StringField.TYPE_STORED,"test1"));
+ doc.add(new Field("text",TextField.TYPE_STORED,"test1"));
+ doc.add(new Field("unindexed",customType3,"test1"));
+ doc.add(new TextField("unstored","test1"));
writer.addDocument(doc);
writer.close();
@@ -180,29 +179,43 @@ public class TestIndexReader extends Luc
int mergeFactor = ((LogMergePolicy) writer.getConfig().getMergePolicy()).getMergeFactor();
for (int i = 0; i < 5*mergeFactor; i++) {
doc = new Document();
- doc.add(new Field("keyword","test1", Field.Store.YES, Field.Index.NOT_ANALYZED));
- doc.add(new Field("text","test1", Field.Store.YES, Field.Index.ANALYZED));
- doc.add(new Field("unindexed","test1", Field.Store.YES, Field.Index.NO));
- doc.add(new Field("unstored","test1", Field.Store.NO, Field.Index.ANALYZED));
+ doc.add(new Field("keyword",StringField.TYPE_STORED,"test1"));
+ doc.add(new Field("text",TextField.TYPE_STORED, "test1"));
+ doc.add(new Field("unindexed",customType3,"test1"));
+ doc.add(new TextField("unstored","test1"));
writer.addDocument(doc);
}
// new fields are in some different segments (we hope)
for (int i = 0; i < 5*mergeFactor; i++) {
doc = new Document();
- doc.add(new Field("keyword2","test1", Field.Store.YES, Field.Index.NOT_ANALYZED));
- doc.add(new Field("text2","test1", Field.Store.YES, Field.Index.ANALYZED));
- doc.add(new Field("unindexed2","test1", Field.Store.YES, Field.Index.NO));
- doc.add(new Field("unstored2","test1", Field.Store.NO, Field.Index.ANALYZED));
+ doc.add(new Field("keyword2",StringField.TYPE_STORED,"test1"));
+ doc.add(new Field("text2",TextField.TYPE_STORED, "test1"));
+ doc.add(new Field("unindexed2",customType3,"test1"));
+ doc.add(new TextField("unstored2","test1"));
writer.addDocument(doc);
}
// new termvector fields
+
+ FieldType customType5 = new FieldType(TextField.TYPE_STORED);
+ customType5.setStoreTermVectors(true);
+ FieldType customType6 = new FieldType(TextField.TYPE_STORED);
+ customType6.setStoreTermVectors(true);
+ customType6.setStoreTermVectorOffsets(true);
+ FieldType customType7 = new FieldType(TextField.TYPE_STORED);
+ customType7.setStoreTermVectors(true);
+ customType7.setStoreTermVectorPositions(true);
+ FieldType customType8 = new FieldType(TextField.TYPE_STORED);
+ customType8.setStoreTermVectors(true);
+ customType8.setStoreTermVectorOffsets(true);
+ customType8.setStoreTermVectorPositions(true);
+
for (int i = 0; i < 5*mergeFactor; i++) {
doc = new Document();
- doc.add(new Field("tvnot","tvnot", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO));
- doc.add(new Field("termvector","termvector", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.YES));
- doc.add(new Field("tvoffset","tvoffset", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_OFFSETS));
- doc.add(new Field("tvposition","tvposition", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS));
- doc.add(newField("tvpositionoffset","tvpositionoffset", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
+ doc.add(new Field("tvnot",TextField.TYPE_STORED,"tvnot"));
+ doc.add(new Field("termvector",customType5,"termvector"));
+ doc.add(new Field("tvoffset",customType6,"tvoffset"));
+ doc.add(new Field("tvposition",customType7,"tvposition"));
+ doc.add(new Field("tvpositionoffset",customType8, "tvpositionoffset"));
writer.addDocument(doc);
}
@@ -277,14 +290,26 @@ public class TestIndexReader extends Luc
// want to get some more segments here
// new termvector fields
int mergeFactor = ((LogMergePolicy) writer.getConfig().getMergePolicy()).getMergeFactor();
+ FieldType customType5 = new FieldType(TextField.TYPE_STORED);
+ customType5.setStoreTermVectors(true);
+ FieldType customType6 = new FieldType(TextField.TYPE_STORED);
+ customType6.setStoreTermVectors(true);
+ customType6.setStoreTermVectorOffsets(true);
+ FieldType customType7 = new FieldType(TextField.TYPE_STORED);
+ customType7.setStoreTermVectors(true);
+ customType7.setStoreTermVectorPositions(true);
+ FieldType customType8 = new FieldType(TextField.TYPE_STORED);
+ customType8.setStoreTermVectors(true);
+ customType8.setStoreTermVectorOffsets(true);
+ customType8.setStoreTermVectorPositions(true);
for (int i = 0; i < 5 * mergeFactor; i++) {
Document doc = new Document();
- doc.add(new Field("tvnot","one two two three three three", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO));
- doc.add(new Field("termvector","one two two three three three", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.YES));
- doc.add(new Field("tvoffset","one two two three three three", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_OFFSETS));
- doc.add(new Field("tvposition","one two two three three three", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS));
- doc.add(new Field("tvpositionoffset","one two two three three three", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
-
+ doc.add(new Field("tvnot",TextField.TYPE_STORED,"one two two three three three"));
+ doc.add(new Field("termvector",customType5,"one two two three three three"));
+ doc.add(new Field("tvoffset",customType6,"one two two three three three"));
+ doc.add(new Field("tvposition",customType7,"one two two three three three"));
+ doc.add(new Field("tvpositionoffset",customType8, "one two two three three three"));
+
writer.addDocument(doc);
}
writer.close();
@@ -338,36 +363,21 @@ public class TestIndexReader extends Luc
writer.close();
writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.APPEND).setMergePolicy(newLogMergePolicy()));
Document doc = new Document();
- doc.add(new Field("bin1", bin));
- doc.add(new Field("junk", "junk text", Field.Store.NO, Field.Index.ANALYZED));
+ doc.add(new BinaryField("bin1", bin));
+ doc.add(new TextField("junk", "junk text"));
writer.addDocument(doc);
writer.close();
IndexReader reader = IndexReader.open(dir, false);
- doc = reader.document(reader.maxDoc() - 1);
- Field[] fields = doc.getFields("bin1");
+ Document doc2 = reader.document(reader.maxDoc() - 1);
+ IndexableField[] fields = doc2.getFields("bin1");
assertNotNull(fields);
assertEquals(1, fields.length);
- Field b1 = fields[0];
- assertTrue(b1.isBinary());
- byte[] data1 = b1.getBinaryValue();
- assertEquals(bin.length, b1.getBinaryLength());
- for (int i = 0; i < bin.length; i++) {
- assertEquals(bin[i], data1[i + b1.getBinaryOffset()]);
- }
- Set<String> lazyFields = new HashSet<String>();
- lazyFields.add("bin1");
- FieldSelector sel = new SetBasedFieldSelector(new HashSet<String>(), lazyFields);
- doc = reader.document(reader.maxDoc() - 1, sel);
- Fieldable[] fieldables = doc.getFieldables("bin1");
- assertNotNull(fieldables);
- assertEquals(1, fieldables.length);
- Fieldable fb1 = fieldables[0];
- assertTrue(fb1.isBinary());
- assertEquals(bin.length, fb1.getBinaryLength());
- data1 = fb1.getBinaryValue();
- assertEquals(bin.length, fb1.getBinaryLength());
+ IndexableField b1 = fields[0];
+ assertTrue(b1.binaryValue() != null);
+ BytesRef bytesRef = b1.binaryValue();
+ assertEquals(bin.length, bytesRef.length);
for (int i = 0; i < bin.length; i++) {
- assertEquals(bin[i], data1[i + fb1.getBinaryOffset()]);
+ assertEquals(bin[i], bytesRef.bytes[i + bytesRef.offset]);
}
reader.close();
// force optimize
@@ -377,16 +387,16 @@ public class TestIndexReader extends Luc
writer.optimize();
writer.close();
reader = IndexReader.open(dir, false);
- doc = reader.document(reader.maxDoc() - 1);
- fields = doc.getFields("bin1");
+ doc2 = reader.document(reader.maxDoc() - 1);
+ fields = doc2.getFields("bin1");
assertNotNull(fields);
assertEquals(1, fields.length);
b1 = fields[0];
- assertTrue(b1.isBinary());
- data1 = b1.getBinaryValue();
- assertEquals(bin.length, b1.getBinaryLength());
+ assertTrue(b1.binaryValue() != null);
+ bytesRef = b1.binaryValue();
+ assertEquals(bin.length, bytesRef.length);
for (int i = 0; i < bin.length; i++) {
- assertEquals(bin[i], data1[i + b1.getBinaryOffset()]);
+ assertEquals(bin[i], bytesRef.bytes[i + bytesRef.offset]);
}
reader.close();
dir.close();
@@ -778,38 +788,56 @@ public class TestIndexReader extends Luc
static void addDocumentWithFields(IndexWriter writer) throws IOException
{
Document doc = new Document();
- doc.add(newField("keyword","test1", Field.Store.YES, Field.Index.NOT_ANALYZED));
- doc.add(newField("text","test1", Field.Store.YES, Field.Index.ANALYZED));
- doc.add(newField("unindexed","test1", Field.Store.YES, Field.Index.NO));
- doc.add(newField("unstored","test1", Field.Store.NO, Field.Index.ANALYZED));
+
+ FieldType customType3 = new FieldType();
+ customType3.setStored(true);
+ doc.add(newField("keyword", "test1", StringField.TYPE_STORED));
+ doc.add(newField("text", "test1", TextField.TYPE_STORED));
+ doc.add(newField("unindexed", "test1", customType3));
+ doc.add(new TextField("unstored","test1"));
writer.addDocument(doc);
}
static void addDocumentWithDifferentFields(IndexWriter writer) throws IOException
{
- Document doc = new Document();
- doc.add(newField("keyword2","test1", Field.Store.YES, Field.Index.NOT_ANALYZED));
- doc.add(newField("text2","test1", Field.Store.YES, Field.Index.ANALYZED));
- doc.add(newField("unindexed2","test1", Field.Store.YES, Field.Index.NO));
- doc.add(newField("unstored2","test1", Field.Store.NO, Field.Index.ANALYZED));
- writer.addDocument(doc);
+ Document doc = new Document();
+
+ FieldType customType3 = new FieldType();
+ customType3.setStored(true);
+ doc.add(newField("keyword2", "test1", StringField.TYPE_STORED));
+ doc.add(newField("text2", "test1", TextField.TYPE_STORED));
+ doc.add(newField("unindexed2", "test1", customType3));
+ doc.add(new TextField("unstored2","test1"));
+ writer.addDocument(doc);
}
static void addDocumentWithTermVectorFields(IndexWriter writer) throws IOException
{
Document doc = new Document();
- doc.add(newField("tvnot","tvnot", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO));
- doc.add(newField("termvector","termvector", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.YES));
- doc.add(newField("tvoffset","tvoffset", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_OFFSETS));
- doc.add(newField("tvposition","tvposition", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS));
- doc.add(newField("tvpositionoffset","tvpositionoffset", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
+ FieldType customType5 = new FieldType(TextField.TYPE_STORED);
+ customType5.setStoreTermVectors(true);
+ FieldType customType6 = new FieldType(TextField.TYPE_STORED);
+ customType6.setStoreTermVectors(true);
+ customType6.setStoreTermVectorOffsets(true);
+ FieldType customType7 = new FieldType(TextField.TYPE_STORED);
+ customType7.setStoreTermVectors(true);
+ customType7.setStoreTermVectorPositions(true);
+ FieldType customType8 = new FieldType(TextField.TYPE_STORED);
+ customType8.setStoreTermVectors(true);
+ customType8.setStoreTermVectorOffsets(true);
+ customType8.setStoreTermVectorPositions(true);
+ doc.add(newField("tvnot","tvnot",TextField.TYPE_STORED));
+ doc.add(newField("termvector","termvector",customType5));
+ doc.add(newField("tvoffset","tvoffset", customType6));
+ doc.add(newField("tvposition","tvposition", customType7));
+ doc.add(newField("tvpositionoffset","tvpositionoffset", customType8));
writer.addDocument(doc);
}
static void addDoc(IndexWriter writer, String value) throws IOException {
Document doc = new Document();
- doc.add(newField("content", value, Field.Store.NO, Field.Index.ANALYZED));
+ doc.add(newField("content", value, TextField.TYPE_UNSTORED));
writer.addDocument(doc);
}
@@ -862,11 +890,11 @@ public class TestIndexReader extends Luc
if (liveDocs1 == null || liveDocs1.get(i)) {
Document doc1 = index1.document(i);
Document doc2 = index2.document(i);
- List<Fieldable> fieldable1 = doc1.getFields();
- List<Fieldable> fieldable2 = doc2.getFields();
- assertEquals("Different numbers of fields for doc " + i + ".", fieldable1.size(), fieldable2.size());
- Iterator<Fieldable> itField1 = fieldable1.iterator();
- Iterator<Fieldable> itField2 = fieldable2.iterator();
+ List<IndexableField> field1 = doc1.getFields();
+ List<IndexableField> field2 = doc2.getFields();
+ assertEquals("Different numbers of fields for doc " + i + ".", field1.size(), field2.size());
+ Iterator<IndexableField> itField1 = field1.iterator();
+ Iterator<IndexableField> itField2 = field2.iterator();
while (itField1.hasNext()) {
Field curField1 = (Field) itField1.next();
Field curField2 = (Field) itField2.next();
@@ -1047,7 +1075,11 @@ public class TestIndexReader extends Luc
static Document createDocument(String id) {
Document doc = new Document();
- doc.add(newField("id", id, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
+ FieldType customType = new FieldType(TextField.TYPE_STORED);
+ customType.setTokenized(false);
+ customType.setOmitNorms(true);
+
+ doc.add(newField("id", id, customType));
return doc;
}
@@ -1097,7 +1129,7 @@ public class TestIndexReader extends Luc
Directory dir = newDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)));
Document doc = new Document();
- doc.add(newField("number", "17", Field.Store.NO, Field.Index.NOT_ANALYZED));
+ doc.add(newField("number", "17", StringField.TYPE_UNSTORED));
writer.addDocument(doc);
writer.close();
@@ -1132,7 +1164,7 @@ public class TestIndexReader extends Luc
setMergePolicy(newLogMergePolicy(10))
);
Document doc = new Document();
- doc.add(newField("number", "17", Field.Store.NO, Field.Index.NOT_ANALYZED));
+ doc.add(newField("number", "17", StringField.TYPE_UNSTORED));
writer.addDocument(doc);
writer.commit();
@@ -1164,8 +1196,8 @@ public class TestIndexReader extends Luc
Directory dir = newDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setCodecProvider(_TestUtil.alwaysCodec("Standard")));
Document doc = new Document();
- doc.add(newField("field", "a b c d e f g h i j k l m n o p q r s t u v w x y z", Field.Store.NO, Field.Index.ANALYZED));
- doc.add(newField("number", "0 1 2 3 4 5 6 7 8 9", Field.Store.NO, Field.Index.ANALYZED));
+ doc.add(newField("field", "a b c d e f g h i j k l m n o p q r s t u v w x y z", TextField.TYPE_UNSTORED));
+ doc.add(newField("number", "0 1 2 3 4 5 6 7 8 9", TextField.TYPE_UNSTORED));
writer.addDocument(doc);
writer.addDocument(doc);
writer.commit();
@@ -1197,8 +1229,8 @@ public class TestIndexReader extends Luc
Directory dir = newDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setCodecProvider(_TestUtil.alwaysCodec("Standard")));
Document doc = new Document();
- doc.add(newField("field", "a b c d e f g h i j k l m n o p q r s t u v w x y z", Field.Store.NO, Field.Index.ANALYZED));
- doc.add(newField("number", "0 1 2 3 4 5 6 7 8 9", Field.Store.NO, Field.Index.ANALYZED));
+ doc.add(newField("field", "a b c d e f g h i j k l m n o p q r s t u v w x y z", TextField.TYPE_UNSTORED));
+ doc.add(newField("number", "0 1 2 3 4 5 6 7 8 9", TextField.TYPE_UNSTORED));
writer.addDocument(doc);
writer.addDocument(doc);
writer.close();
@@ -1302,7 +1334,7 @@ public class TestIndexReader extends Luc
Directory dir = newDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)));
Document d = new Document();
- d.add(newField("f", "a a b", Field.Index.ANALYZED));
+ d.add(newField("f", "a a b", TextField.TYPE_UNSTORED));
writer.addDocument(d);
IndexReader r = writer.getReader();
writer.close();
Modified: lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderClone.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderClone.java?rev=1163047&r1=1163046&r2=1163047&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderClone.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderClone.java Mon Aug 29 23:13:10 2011
@@ -17,12 +17,10 @@ package org.apache.lucene.index;
* limitations under the License.
*/
-import org.apache.lucene.index.SegmentNorms;
import org.apache.lucene.search.similarities.DefaultSimilarity;
-import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
+import org.apache.lucene.document.TextField;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.LockObtainFailedException;
import org.apache.lucene.util.LuceneTestCase;
@@ -500,7 +498,7 @@ public class TestIndexReaderClone extend
setMergePolicy(newLogMergePolicy(false))
);
Document doc = new Document();
- doc.add(newField("field", "yes it's stored", Field.Store.YES, Field.Index.ANALYZED));
+ doc.add(newField("field", "yes it's stored", TextField.TYPE_STORED));
w.addDocument(doc);
w.close();
IndexReader r1 = IndexReader.open(dir, false);
Modified: lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java?rev=1163047&r1=1163046&r2=1163047&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java Mon Aug 29 23:13:10 2011
@@ -26,10 +26,9 @@ import org.apache.lucene.analysis.Analyz
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
-import org.apache.lucene.document.Field.Index;
-import org.apache.lucene.document.Field.Store;
+import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
-import org.apache.lucene.index.SegmentNorms;
import org.apache.lucene.search.similarities.DefaultSimilarity;
import org.apache.lucene.search.similarities.DefaultSimilarityProvider;
import org.apache.lucene.search.similarities.Similarity;
@@ -329,8 +328,11 @@ public class TestIndexReaderCloneNorms e
private Document newDoc() {
Document d = new Document();
float boost = nextNorm("anyfield"); // in this test the same similarity is used for all fields so it does not matter what field is passed
+
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setTokenized(false);
for (int i = 0; i < 10; i++) {
- Field f = newField("f" + i, "v" + i, Store.NO, Index.NOT_ANALYZED);
+ Field f = newField("f" + i, "v" + i, customType);
f.setBoost(boost);
d.add(f);
}
Modified: lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderDelete.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderDelete.java?rev=1163047&r1=1163046&r2=1163047&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderDelete.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderDelete.java Mon Aug 29 23:13:10 2011
@@ -21,7 +21,7 @@ import java.io.IOException;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StringField;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockDirectoryWrapper;
@@ -276,11 +276,11 @@ public class TestIndexReaderDelete exten
Directory dir = newDirectory();
RandomIndexWriter w= new RandomIndexWriter(random, dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMergePolicy(newLogMergePolicy()));
Document doc = new Document();
- doc.add(newField("f", "doctor", Field.Store.NO, Field.Index.NOT_ANALYZED));
+ doc.add(newField("f", "doctor", StringField.TYPE_UNSTORED));
w.addDocument(doc);
doc = new Document();
w.commit();
- doc.add(newField("f", "who", Field.Store.NO, Field.Index.NOT_ANALYZED));
+ doc.add(newField("f", "who", StringField.TYPE_UNSTORED));
w.addDocument(doc);
IndexReader r = new SlowMultiReaderWrapper(w.getReader());
w.close();
Modified: lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderOnDiskFull.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderOnDiskFull.java?rev=1163047&r1=1163046&r2=1163047&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderOnDiskFull.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderOnDiskFull.java Mon Aug 29 23:13:10 2011
@@ -21,7 +21,8 @@ import java.io.IOException;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StringField;
+import org.apache.lucene.document.TextField;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
@@ -52,8 +53,8 @@ public class TestIndexReaderOnDiskFull e
}
for(int i=0;i<157;i++) {
Document d = new Document();
- d.add(newField("id", Integer.toString(i), Field.Store.YES, Field.Index.NOT_ANALYZED));
- d.add(newField("content", "aaa " + i, Field.Store.NO, Field.Index.ANALYZED));
+ d.add(newField("id", Integer.toString(i), StringField.TYPE_STORED));
+ d.add(newField("content", "aaa " + i, TextField.TYPE_UNSTORED));
writer.addDocument(d);
if (0==i%10)
writer.commit();
Modified: lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java?rev=1163047&r1=1163046&r2=1163047&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexReaderReopen.java Mon Aug 29 23:13:10 2011
@@ -17,7 +17,6 @@ package org.apache.lucene.index;
* limitations under the License.
*/
-import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
@@ -31,9 +30,10 @@ import java.util.Set;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field.Index;
-import org.apache.lucene.document.Field.Store;
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.IndexWriterConfig.OpenMode;
import org.apache.lucene.search.FieldCache;
import org.apache.lucene.search.IndexSearcher;
@@ -168,12 +168,19 @@ public class TestIndexReaderReopen exten
IndexReader reader = IndexReader.open(dir, false);
try {
int M = 3;
+ FieldType customType = new FieldType(TextField.TYPE_STORED);
+ customType.setTokenized(false);
+ FieldType customType2 = new FieldType(TextField.TYPE_STORED);
+ customType2.setTokenized(false);
+ customType2.setOmitNorms(true);
+ FieldType customType3 = new FieldType();
+ customType3.setStored(true);
for (int i=0; i<4; i++) {
for (int j=0; j<M; j++) {
Document doc = new Document();
- doc.add(newField("id", i+"_"+j, Store.YES, Index.NOT_ANALYZED));
- doc.add(newField("id2", i+"_"+j, Store.YES, Index.NOT_ANALYZED_NO_NORMS));
- doc.add(newField("id3", i+"_"+j, Store.YES, Index.NO));
+ doc.add(newField("id", i+"_"+j, customType));
+ doc.add(newField("id2", i+"_"+j, customType2));
+ doc.add(newField("id3", i+"_"+j, customType3));
iwriter.addDocument(doc);
if (i>0) {
int k = i-1;
@@ -957,13 +964,18 @@ public class TestIndexReaderReopen exten
Document doc = new Document();
sb.append("a");
sb.append(n);
- doc.add(new Field("field1", sb.toString(), Store.YES, Index.ANALYZED));
- doc.add(new Field("fielda", sb.toString(), Store.YES, Index.NOT_ANALYZED_NO_NORMS));
- doc.add(new Field("fieldb", sb.toString(), Store.YES, Index.NO));
+ FieldType customType2 = new FieldType(TextField.TYPE_STORED);
+ customType2.setTokenized(false);
+ customType2.setOmitNorms(true);
+ FieldType customType3 = new FieldType();
+ customType3.setStored(true);
+ doc.add(new Field("field1", TextField.TYPE_STORED, sb.toString()));
+ doc.add(new Field("fielda", customType2, sb.toString()));
+ doc.add(new Field("fieldb", customType3, sb.toString()));
sb.append(" b");
sb.append(n);
for (int i = 1; i < numFields; i++) {
- doc.add(new Field("field" + (i+1), sb.toString(), Store.YES, Index.ANALYZED));
+ doc.add(new Field("field" + (i+1), TextField.TYPE_STORED, sb.toString()));
}
return doc;
}
@@ -1178,7 +1190,7 @@ public class TestIndexReaderReopen exten
);
for(int i=0;i<4;i++) {
Document doc = new Document();
- doc.add(newField("id", ""+i, Field.Store.NO, Field.Index.NOT_ANALYZED));
+ doc.add(newField("id", ""+i, StringField.TYPE_UNSTORED));
writer.addDocument(doc);
Map<String,String> data = new HashMap<String,String>();
data.put("index", i+"");
@@ -1239,7 +1251,7 @@ public class TestIndexReaderReopen exten
setMergePolicy(newLogMergePolicy(10))
);
Document doc = new Document();
- doc.add(newField("number", "17", Field.Store.NO, Field.Index.NOT_ANALYZED));
+ doc.add(newField("number", "17", StringField.TYPE_UNSTORED));
writer.addDocument(doc);
writer.commit();
Modified: lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=1163047&r1=1163046&r2=1163047&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java Mon Aug 29 23:13:10 2011
@@ -26,28 +26,23 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
-import org.apache.lucene.analysis.MockFixedLengthPayloadFilter;
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
+import org.apache.lucene.document.BinaryField;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field.Index;
-import org.apache.lucene.document.Field.Store;
-import org.apache.lucene.document.Field.TermVector;
import org.apache.lucene.document.Field;
-import org.apache.lucene.document.Fieldable;
+import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.FieldCache;
@@ -60,7 +55,6 @@ import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.spans.SpanTermQuery;
import org.apache.lucene.store.AlreadyClosedException;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexOutput;
import org.apache.lucene.store.Lock;
import org.apache.lucene.store.LockFactory;
@@ -69,15 +63,13 @@ import org.apache.lucene.store.NoLockFac
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.store.SingleInstanceLockFactory;
import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.CharsRef;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.ThreadInterruptedException;
-import org.apache.lucene.util.UnicodeUtil;
import org.apache.lucene.util._TestUtil;
-import org.apache.lucene.index.codecs.preflexrw.PreFlexRWCodec;
public class TestIndexWriter extends LuceneTestCase {
+ private static final FieldType storedTextType = new FieldType(TextField.TYPE_UNSTORED);
public void testDocCount() throws IOException {
Directory dir = newDirectory();
@@ -138,15 +130,15 @@ public class TestIndexWriter extends Luc
static void addDoc(IndexWriter writer) throws IOException
{
Document doc = new Document();
- doc.add(newField("content", "aaa", Field.Store.NO, Field.Index.ANALYZED));
+ doc.add(newField("content", "aaa", TextField.TYPE_UNSTORED));
writer.addDocument(doc);
}
static void addDocWithIndex(IndexWriter writer, int index) throws IOException
{
Document doc = new Document();
- doc.add(newField("content", "aaa " + index, Field.Store.YES, Field.Index.ANALYZED));
- doc.add(newField("id", "" + index, Field.Store.YES, Field.Index.ANALYZED));
+ doc.add(newField("content", "aaa " + index, storedTextType));
+ doc.add(newField("id", "" + index, storedTextType));
writer.addDocument(doc);
}
@@ -256,12 +248,12 @@ public class TestIndexWriter extends Luc
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMaxBufferedDocs(10));
for(int j=0;j<100;j++) {
Document doc = new Document();
- doc.add(newField("a"+j, "aaa" + j, Field.Store.YES, Field.Index.ANALYZED));
- doc.add(newField("b"+j, "aaa" + j, Field.Store.YES, Field.Index.ANALYZED));
- doc.add(newField("c"+j, "aaa" + j, Field.Store.YES, Field.Index.ANALYZED));
- doc.add(newField("d"+j, "aaa", Field.Store.YES, Field.Index.ANALYZED));
- doc.add(newField("e"+j, "aaa", Field.Store.YES, Field.Index.ANALYZED));
- doc.add(newField("f"+j, "aaa", Field.Store.YES, Field.Index.ANALYZED));
+ doc.add(newField("a"+j, "aaa" + j, storedTextType));
+ doc.add(newField("b"+j, "aaa" + j, storedTextType));
+ doc.add(newField("c"+j, "aaa" + j, storedTextType));
+ doc.add(newField("d"+j, "aaa", storedTextType));
+ doc.add(newField("e"+j, "aaa", storedTextType));
+ doc.add(newField("f"+j, "aaa", storedTextType));
writer.addDocument(doc);
}
writer.close();
@@ -292,7 +284,7 @@ public class TestIndexWriter extends Luc
int lastNumFile = dir.listAll().length;
for(int j=0;j<9;j++) {
Document doc = new Document();
- doc.add(newField("field", "aaa" + j, Field.Store.YES, Field.Index.ANALYZED));
+ doc.add(newField("field", "aaa" + j, storedTextType));
writer.addDocument(doc);
int numFile = dir.listAll().length;
// Verify that with a tiny RAM buffer we see new
@@ -315,7 +307,7 @@ public class TestIndexWriter extends Luc
int lastFlushCount = -1;
for(int j=1;j<52;j++) {
Document doc = new Document();
- doc.add(new Field("field", "aaa" + j, Field.Store.YES, Field.Index.ANALYZED));
+ doc.add(new Field("field", storedTextType, "aaa" + j));
writer.addDocument(doc);
_TestUtil.syncConcurrentMerges(writer);
int flushCount = writer.getFlushCount();
@@ -369,7 +361,7 @@ public class TestIndexWriter extends Luc
for(int j=1;j<52;j++) {
Document doc = new Document();
- doc.add(new Field("field", "aaa" + j, Field.Store.YES, Field.Index.ANALYZED));
+ doc.add(new Field("field", storedTextType, "aaa" + j));
writer.addDocument(doc);
}
@@ -430,7 +422,7 @@ public class TestIndexWriter extends Luc
for(int j=0;j<100;j++) {
Document doc = new Document();
for(int k=0;k<100;k++) {
- doc.add(newField("field", Integer.toString(random.nextInt()), Field.Store.YES, Field.Index.ANALYZED));
+ doc.add(newField("field", Integer.toString(random.nextInt()), storedTextType));
}
writer.addDocument(doc);
}
@@ -439,7 +431,7 @@ public class TestIndexWriter extends Luc
// occurs (heavy on byte blocks)
for(int j=0;j<100;j++) {
Document doc = new Document();
- doc.add(newField("field", "aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa", Field.Store.YES, Field.Index.ANALYZED));
+ doc.add(newField("field", "aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa", storedTextType));
writer.addDocument(doc);
}
@@ -454,7 +446,7 @@ public class TestIndexWriter extends Luc
String longTerm = b.toString();
Document doc = new Document();
- doc.add(newField("field", longTerm, Field.Store.YES, Field.Index.ANALYZED));
+ doc.add(newField("field", longTerm, storedTextType));
writer.addDocument(doc);
}
}
@@ -472,11 +464,16 @@ public class TestIndexWriter extends Luc
MockDirectoryWrapper dir = newDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMaxBufferedDocs(10));
// Enable norms for only 1 doc, pre flush
+ FieldType customType = new FieldType(TextField.TYPE_STORED);
+ customType.setOmitNorms(true);
for(int j=0;j<10;j++) {
Document doc = new Document();
- Field f = newField("field", "aaa", Field.Store.YES, Field.Index.ANALYZED);
+ Field f = null;
if (j != 8) {
- f.setOmitNorms(true);
+ f = newField("field", "aaa", customType);
+ }
+ else {
+ f = newField("field", "aaa", storedTextType);
}
doc.add(f);
writer.addDocument(doc);
@@ -495,9 +492,12 @@ public class TestIndexWriter extends Luc
// Enable norms for only 1 doc, post flush
for(int j=0;j<27;j++) {
Document doc = new Document();
- Field f = newField("field", "aaa", Field.Store.YES, Field.Index.ANALYZED);
+ Field f = null;
if (j != 26) {
- f.setOmitNorms(true);
+ f = newField("field", "aaa", customType);
+ }
+ else {
+ f = newField("field", "aaa", storedTextType);
}
doc.add(f);
writer.addDocument(doc);
@@ -527,7 +527,11 @@ public class TestIndexWriter extends Luc
b.append(" a a a a a a a a");
}
Document doc = new Document();
- doc.add(newField("field", b.toString(), Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
+ FieldType customType = new FieldType(TextField.TYPE_STORED);
+ customType.setStoreTermVectors(true);
+ customType.setStoreTermVectorPositions(true);
+ customType.setStoreTermVectorOffsets(true);
+ doc.add(newField("field", b.toString(), customType));
writer.addDocument(doc);
writer.close();
@@ -595,7 +599,11 @@ public class TestIndexWriter extends Luc
setMergePolicy(newLogMergePolicy(10))
);
Document doc = new Document();
- doc.add(newField("field", "aaa", Store.YES, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS));
+ FieldType customType = new FieldType(TextField.TYPE_STORED);
+ customType.setStoreTermVectors(true);
+ customType.setStoreTermVectorPositions(true);
+ customType.setStoreTermVectorOffsets(true);
+ doc.add(newField("field", "aaa", customType));
for(int i=0;i<19;i++)
writer.addDocument(doc);
writer.flush(false, true);
@@ -615,7 +623,11 @@ public class TestIndexWriter extends Luc
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)));
writer.setInfoStream(VERBOSE ? System.out : null);
Document doc = new Document();
- doc.add(newField("field", "aaa", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
+ FieldType customType = new FieldType(TextField.TYPE_STORED);
+ customType.setStoreTermVectors(true);
+ customType.setStoreTermVectorPositions(true);
+ customType.setStoreTermVectorOffsets(true);
+ doc.add(newField("field", "aaa", customType));
writer.addDocument(doc);
writer.commit();
if (VERBOSE) {
@@ -644,7 +656,9 @@ public class TestIndexWriter extends Luc
TEST_VERSION_CURRENT, new MockAnalyzer(random)));
Document document = new Document();
- document.add(newField("tvtest", "", Store.NO, Index.ANALYZED, TermVector.YES));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStoreTermVectors(true);
+ document.add(newField("tvtest", "", customType));
iw.addDocument(document);
iw.close();
dir.close();
@@ -661,8 +675,9 @@ public class TestIndexWriter extends Luc
((LogMergePolicy) conf.getMergePolicy()).setMergeFactor(2);
IndexWriter iw = new IndexWriter(dir, conf);
Document document = new Document();
- document.add(newField("tvtest", "a b c", Field.Store.NO, Field.Index.ANALYZED,
- Field.TermVector.YES));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStoreTermVectors(true);
+ document.add(newField("tvtest", "a b c", customType));
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
for(int i=0;i<4;i++)
iw.addDocument(document);
@@ -688,24 +703,20 @@ public class TestIndexWriter extends Luc
Document doc = new Document();
String contents = "aa bb cc dd ee ff gg hh ii jj kk";
+ FieldType customType = new FieldType(TextField.TYPE_STORED);
+ FieldType type = null;
if (i == 7) {
// Add empty docs here
- doc.add(newField("content3", "", Field.Store.NO,
- Field.Index.ANALYZED));
+ doc.add(newField("content3", "", TextField.TYPE_UNSTORED));
} else {
- Field.Store storeVal;
if (i%2 == 0) {
- doc.add(newField("content4", contents, Field.Store.YES,
- Field.Index.ANALYZED));
- storeVal = Field.Store.YES;
+ doc.add(newField("content4", contents, customType));
+ type = customType;
} else
- storeVal = Field.Store.NO;
- doc.add(newField("content1", contents, storeVal,
- Field.Index.ANALYZED));
- doc.add(newField("content3", "", Field.Store.YES,
- Field.Index.ANALYZED));
- doc.add(newField("content5", "", storeVal,
- Field.Index.ANALYZED));
+ type = TextField.TYPE_UNSTORED;
+ doc.add(newField("content1", contents, TextField.TYPE_UNSTORED));
+ doc.add(newField("content3", "", customType));
+ doc.add(newField("content5", "", type));
}
for(int j=0;j<4;j++)
@@ -731,7 +742,10 @@ public class TestIndexWriter extends Luc
Directory directory = newDirectory();
final Document doc = new Document();
- Field idField = newField("id", "", Field.Store.YES, Field.Index.NOT_ANALYZED);
+ FieldType customType = new FieldType(TextField.TYPE_STORED);
+ customType.setTokenized(false);
+
+ Field idField = newField("id", "", customType);
doc.add(idField);
for(int pass=0;pass<2;pass++) {
@@ -835,7 +849,7 @@ public class TestIndexWriter extends Luc
for(int i=0;i<10000;i++)
b.append(" a");
b.append(" x");
- doc.add(newField("field", b.toString(), Field.Store.NO, Field.Index.ANALYZED));
+ doc.add(newField("field", b.toString(), TextField.TYPE_UNSTORED));
writer.addDocument(doc);
writer.close();
@@ -853,7 +867,7 @@ public class TestIndexWriter extends Luc
Directory dir = newDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)));
Document doc = new Document();
- doc.add(newField("", "a b c", Field.Store.NO, Field.Index.ANALYZED));
+ doc.add(newField("", "a b c", TextField.TYPE_UNSTORED));
writer.addDocument(doc);
writer.close();
dir.close();
@@ -887,8 +901,8 @@ public class TestIndexWriter extends Luc
Directory dir = newDirectory();
MockIndexWriter w = new MockIndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)));
Document doc = new Document();
- doc.add(newField("field", "a field", Field.Store.YES,
- Field.Index.ANALYZED));
+ FieldType customType = new FieldType(TextField.TYPE_STORED);
+ doc.add(newField("field", "a field", customType));
w.addDocument(doc);
w.commit();
assertTrue(w.beforeWasCalled);
@@ -931,7 +945,7 @@ public class TestIndexWriter extends Luc
Directory dir = newDirectory();
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)));
Document doc = new Document();
- doc.add(new Field("field", tokens));
+ doc.add(new TextField("field", tokens));
w.addDocument(doc);
w.commit();
@@ -972,20 +986,20 @@ public class TestIndexWriter extends Luc
b[i] = (byte) (i+77);
Document doc = new Document();
- Field f = new Field("binary", b, 10, 17);
- byte[] bx = f.getBinaryValue();
+ Field f = new BinaryField("binary", b, 10, 17);
+ byte[] bx = f.binaryValue().bytes;
assertTrue(bx != null);
assertEquals(50, bx.length);
- assertEquals(10, f.getBinaryOffset());
- assertEquals(17, f.getBinaryLength());
+ assertEquals(10, f.binaryValue().offset);
+ assertEquals(17, f.binaryValue().length);
doc.add(f);
w.addDocument(doc);
w.close();
IndexReader ir = IndexReader.open(dir, true);
- doc = ir.document(0);
- f = doc.getField("binary");
- b = f.getBinaryValue();
+ Document doc2 = ir.document(0);
+ IndexableField f2 = doc2.getField("binary");
+ b = f2.binaryValue().bytes;
assertTrue(b != null);
assertEquals(17, b.length, 17);
assertEquals(87, b[0]);
@@ -1001,10 +1015,11 @@ public class TestIndexWriter extends Luc
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, analyzer));
Document doc = new Document();
- Field f = newField("field", "", Field.Store.NO,
- Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS);
- Field f2 = newField("field", "crunch man", Field.Store.NO,
- Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS);
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStoreTermVectors(true);
+ customType.setStoreTermVectorPositions(true);
+ Field f = newField("field", "", customType);
+ Field f2 = newField("field", "crunch man", customType);
doc.add(f);
doc.add(f2);
w.addDocument(doc);
@@ -1046,8 +1061,13 @@ public class TestIndexWriter extends Luc
Directory dir = newDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMaxBufferedDocs(2));
Document doc = new Document();
- doc.add(newField("content", "aaa bbb ccc ddd eee fff ggg hhh iii", Field.Store.YES,
- Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
+
+ FieldType customType = new FieldType(TextField.TYPE_STORED);
+ customType.setStoreTermVectors(true);
+ customType.setStoreTermVectorPositions(true);
+ customType.setStoreTermVectorOffsets(true);
+
+ doc.add(newField("content", "aaa bbb ccc ddd eee fff ggg hhh iii", customType));
writer.addDocument(doc);
writer.addDocument(doc);
writer.addDocument(doc);
@@ -1099,7 +1119,7 @@ public class TestIndexWriter extends Luc
w = new IndexWriter(dir, conf);
Document doc = new Document();
- doc.add(newField("field", "some text contents", Field.Store.YES, Field.Index.ANALYZED));
+ doc.add(newField("field", "some text contents", storedTextType));
for(int i=0;i<100;i++) {
w.addDocument(doc);
if (i%10 == 0) {
@@ -1213,9 +1233,17 @@ public class TestIndexWriter extends Luc
b[i] = (byte) (i+77);
Document doc = new Document();
- Field f = new Field("binary", b, 10, 17);
+
+ FieldType customType = new FieldType(BinaryField.TYPE_STORED);
+ customType.setTokenized(true);
+ customType.setIndexed(true);
+
+ Field f = new Field("binary", customType, b, 10, 17);
f.setTokenStream(new MockTokenizer(new StringReader("doc1field1"), MockTokenizer.WHITESPACE, false));
- Field f2 = newField("string", "value", Field.Store.YES,Field.Index.ANALYZED);
+
+ FieldType customType2 = new FieldType(TextField.TYPE_STORED);
+
+ Field f2 = newField("string", "value", customType2);
f2.setTokenStream(new MockTokenizer(new StringReader("doc1field2"), MockTokenizer.WHITESPACE, false));
doc.add(f);
doc.add(f2);
@@ -1238,16 +1266,16 @@ public class TestIndexWriter extends Luc
w.close();
IndexReader ir = IndexReader.open(dir, true);
- doc = ir.document(0);
- f = doc.getField("binary");
- b = f.getBinaryValue();
+ Document doc2 = ir.document(0);
+ IndexableField f3 = doc2.getField("binary");
+ b = f3.binaryValue().bytes;
assertTrue(b != null);
assertEquals(17, b.length, 17);
assertEquals(87, b[0]);
- assertTrue(ir.document(0).getFieldable("binary").isBinary());
- assertTrue(ir.document(1).getFieldable("binary").isBinary());
- assertTrue(ir.document(2).getFieldable("binary").isBinary());
+ assertTrue(ir.document(0).getField("binary").binaryValue()!=null);
+ assertTrue(ir.document(1).getField("binary").binaryValue()!=null);
+ assertTrue(ir.document(2).getField("binary").binaryValue()!=null);
assertEquals("value", ir.document(0).get("string"));
assertEquals("value", ir.document(1).get("string"));
@@ -1272,13 +1300,16 @@ public class TestIndexWriter extends Luc
Directory d = newDirectory();
IndexWriter w = new IndexWriter(d, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)));
Document doc = new Document();
- doc.add(newField("zzz", "a b c", Field.Store.YES, Field.Index.NO));
- doc.add(newField("aaa", "a b c", Field.Store.YES, Field.Index.NO));
- doc.add(newField("zzz", "1 2 3", Field.Store.YES, Field.Index.NO));
+
+ FieldType customType = new FieldType();
+ customType.setStored(true);
+ doc.add(newField("zzz", "a b c", customType));
+ doc.add(newField("aaa", "a b c", customType));
+ doc.add(newField("zzz", "1 2 3", customType));
w.addDocument(doc);
IndexReader r = w.getReader();
- doc = r.document(0);
- Iterator<Fieldable> it = doc.getFields().iterator();
+ Document doc2 = r.document(0);
+ Iterator<IndexableField> it = doc2.getFields().iterator();
assertTrue(it.hasNext());
Field f = (Field) it.next();
assertEquals(f.name(), "zzz");
@@ -1322,7 +1353,7 @@ public class TestIndexWriter extends Luc
s.append(' ').append(i);
}
Document d = new Document();
- Field f = newField("field", s.toString(), Field.Store.NO, Field.Index.ANALYZED);
+ Field f = newField("field", s.toString(), TextField.TYPE_UNSTORED);
d.add(f);
w.addDocument(d);
@@ -1354,7 +1385,7 @@ public class TestIndexWriter extends Luc
setMergePolicy(mergePolicy)
);
Document doc = new Document();
- doc.add(newField("field", "go", Field.Store.NO, Field.Index.ANALYZED));
+ doc.add(newField("field", "go", TextField.TYPE_UNSTORED));
w.addDocument(doc);
IndexReader r;
if (iter == 0) {
@@ -1422,7 +1453,13 @@ public class TestIndexWriter extends Luc
// First commit
Document doc = new Document();
- doc.add(newField("c", "val", Store.YES, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS));
+
+ FieldType customType = new FieldType(TextField.TYPE_STORED);
+ customType.setStoreTermVectors(true);
+ customType.setStoreTermVectorPositions(true);
+ customType.setStoreTermVectorOffsets(true);
+
+ doc.add(newField("c", "val", customType));
writer.addDocument(doc);
writer.commit();
assertEquals(1, IndexReader.listCommits(dir).size());
@@ -1432,7 +1469,7 @@ public class TestIndexWriter extends Luc
// Second commit - now KeepOnlyLastCommit cannot delete the prev commit.
doc = new Document();
- doc.add(newField("c", "val", Store.YES, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS));
+ doc.add(newField("c", "val", customType));
writer.addDocument(doc);
writer.commit();
assertEquals(2, IndexReader.listCommits(dir).size());
@@ -1479,14 +1516,18 @@ public class TestIndexWriter extends Luc
}
Document doc = new Document();
+ FieldType customType = new FieldType(TextField.TYPE_STORED);
+ customType.setStoreTermVectors(true);
+ customType.setStoreTermVectorPositions(true);
+ customType.setStoreTermVectorOffsets(true);
// create as many files as possible
- doc.add(newField("c", "val", Store.YES, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS));
+ doc.add(newField("c", "val", customType));
writer.addDocument(doc);
// Adding just one document does not call flush yet.
assertEquals("only the stored and term vector files should exist in the directory", 5 + extraFileCount, dir.listAll().length);
doc = new Document();
- doc.add(newField("c", "val", Store.YES, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS));
+ doc.add(newField("c", "val", customType));
writer.addDocument(doc);
// The second document should cause a flush.
@@ -1509,7 +1550,11 @@ public class TestIndexWriter extends Luc
TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMaxBufferedDocs(2));
Document doc = new Document();
- doc.add(newField("c", "val", Store.YES, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS));
+ FieldType customType = new FieldType(TextField.TYPE_STORED);
+ customType.setStoreTermVectors(true);
+ customType.setStoreTermVectorPositions(true);
+ customType.setStoreTermVectorOffsets(true);
+ doc.add(newField("c", "val", customType));
w.addDocument(doc);
w.addDocument(doc);
IndexWriter w2 = new IndexWriter(dir, newIndexWriterConfig(
@@ -1536,7 +1581,9 @@ public class TestIndexWriter extends Luc
final List<Integer> fieldIDs = new ArrayList<Integer>();
- Field idField = newField("id", "", Field.Store.YES, Field.Index.NOT_ANALYZED);
+ FieldType customType = new FieldType(TextField.TYPE_STORED);
+ customType.setTokenized(false);
+ Field idField = newField("id", "", customType);
for(int i=0;i<fieldCount;i++) {
fieldIDs.add(i);
@@ -1548,6 +1595,8 @@ public class TestIndexWriter extends Luc
System.out.println("TEST: build index docCount=" + docCount);
}
+ FieldType customType2 = new FieldType();
+ customType2.setStored(true);
for(int i=0;i<docCount;i++) {
Document doc = new Document();
doc.add(idField);
@@ -1562,7 +1611,7 @@ public class TestIndexWriter extends Luc
final String s;
if (rand.nextInt(4) != 3) {
s = _TestUtil.randomUnicodeString(rand, 1000);
- doc.add(newField("f"+field, s, Field.Store.YES, Field.Index.NO));
+ doc.add(newField("f"+field, s, customType2));
} else {
s = null;
}
@@ -1628,12 +1677,20 @@ public class TestIndexWriter extends Luc
String BIG="alskjhlaksjghlaksjfhalksvjepgjioefgjnsdfjgefgjhelkgjhqewlrkhgwlekgrhwelkgjhwelkgrhwlkejg";
BIG=BIG+BIG+BIG+BIG;
+ FieldType customType = new FieldType(TextField.TYPE_STORED);
+ customType.setOmitNorms(true);
+ FieldType customType2 = new FieldType(TextField.TYPE_STORED);
+ customType2.setTokenized(false);
+ FieldType customType3 = new FieldType(TextField.TYPE_STORED);
+ customType3.setTokenized(false);
+ customType3.setOmitNorms(true);
+
for (int i=0; i<2; i++) {
Document doc = new Document();
- doc.add(new Field("id", Integer.toString(i)+BIG, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
- doc.add(new Field("str", Integer.toString(i)+BIG, Field.Store.YES, Field.Index.NOT_ANALYZED));
- doc.add(new Field("str2", Integer.toString(i)+BIG, Field.Store.YES, Field.Index.ANALYZED));
- doc.add(new Field("str3", Integer.toString(i)+BIG, Field.Store.YES, Field.Index.ANALYZED_NO_NORMS));
+ doc.add(new Field("id", customType3, Integer.toString(i)+BIG));
+ doc.add(new Field("str", customType2, Integer.toString(i)+BIG));
+ doc.add(new Field("str2", storedTextType, Integer.toString(i)+BIG));
+ doc.add(new Field("str3", customType, Integer.toString(i)+BIG));
indexWriter.addDocument(doc);
}
@@ -1713,12 +1770,12 @@ public class TestIndexWriter extends Luc
// This contents produces a too-long term:
String contents = "abc xyz x" + bigTerm + " another term";
- doc.add(new Field("content", contents, Field.Store.NO, Field.Index.ANALYZED));
+ doc.add(new TextField("content", contents));
w.addDocument(doc);
// Make sure we can add another normal document
doc = new Document();
- doc.add(new Field("content", "abc bbb ccc", Field.Store.NO, Field.Index.ANALYZED));
+ doc.add(new TextField("content", "abc bbb ccc"));
w.addDocument(doc);
IndexReader reader = w.getReader();
@@ -1748,7 +1805,9 @@ public class TestIndexWriter extends Luc
// Make sure we can add a document with exactly the
// maximum length term, and search on that term:
doc = new Document();
- Field contentField = new Field("content", "", Field.Store.NO, Field.Index.NOT_ANALYZED);
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setTokenized(false);
+ Field contentField = new Field("content", customType, "");
doc.add(contentField);
w = new RandomIndexWriter(random, dir);
@@ -1785,7 +1844,7 @@ public class TestIndexWriter extends Luc
iwc.setReaderTermsIndexDivisor(1);
IndexWriter writer = new IndexWriter(dir, iwc);
Document doc = new Document();
- doc.add(newField("", "a b c", Field.Store.NO, Field.Index.ANALYZED));
+ doc.add(newField("", "a b c", TextField.TYPE_UNSTORED));
writer.addDocument(doc);
writer.close();
dir.close();
Modified: lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexWriterCommit.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexWriterCommit.java?rev=1163047&r1=1163046&r2=1163047&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexWriterCommit.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexWriterCommit.java Mon Aug 29 23:13:10 2011
@@ -30,6 +30,7 @@ import org.apache.lucene.analysis.MockTo
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StringField;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.index.codecs.CodecProvider;
import org.apache.lucene.search.IndexSearcher;
@@ -342,7 +343,7 @@ public class TestIndexWriterCommit exten
try {
final Document doc = new Document();
IndexReader r = IndexReader.open(dir);
- Field f = newField("f", "", Field.Store.NO, Field.Index.NOT_ANALYZED);
+ Field f = newField("f", "", StringField.TYPE_UNSTORED);
doc.add(f);
int count = 0;
do {
Modified: lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java?rev=1163047&r1=1163046&r2=1163047&view=diff
==============================================================================
--- lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java (original)
+++ lucene/dev/branches/flexscoring/lucene/src/test/org/apache/lucene/index/TestIndexWriterDelete.java Mon Aug 29 23:13:10 2011
@@ -31,7 +31,9 @@ import org.apache.lucene.analysis.MockAn
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.document.Document;
-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.search.IndexSearcher;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.TermQuery;
@@ -55,17 +57,14 @@ public class TestIndexWriterDelete exten
IndexWriter modifier = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(random, MockTokenizer.WHITESPACE, false)).setMaxBufferedDeleteTerms(1));
+ FieldType custom1 = new FieldType();
+ custom1.setStored(true);
for (int i = 0; i < keywords.length; i++) {
Document doc = new Document();
- doc.add(newField("id", keywords[i], Field.Store.YES,
- Field.Index.NOT_ANALYZED));
- doc.add(newField("country", unindexed[i], Field.Store.YES,
- Field.Index.NO));
- doc.add(newField("contents", unstored[i], Field.Store.NO,
- Field.Index.ANALYZED));
- doc
- .add(newField("city", text[i], Field.Store.YES,
- Field.Index.ANALYZED));
+ doc.add(newField("id", keywords[i], StringField.TYPE_STORED));
+ doc.add(newField("country", unindexed[i], custom1));
+ doc.add(newField("contents", unstored[i], TextField.TYPE_UNSTORED));
+ doc.add(newField("city", text[i], TextField.TYPE_STORED));
modifier.addDocument(doc);
}
modifier.optimize();
@@ -390,11 +389,9 @@ public class TestIndexWriterDelete exten
private void updateDoc(IndexWriter modifier, int id, int value)
throws IOException {
Document doc = new Document();
- doc.add(newField("content", "aaa", Field.Store.NO, Field.Index.ANALYZED));
- doc.add(newField("id", String.valueOf(id), Field.Store.YES,
- Field.Index.NOT_ANALYZED));
- doc.add(newField("value", String.valueOf(value), Field.Store.NO,
- Field.Index.NOT_ANALYZED));
+ doc.add(newField("content", "aaa", TextField.TYPE_UNSTORED));
+ doc.add(newField("id", String.valueOf(id), StringField.TYPE_STORED));
+ doc.add(newField("value", String.valueOf(value), StringField.TYPE_UNSTORED));
modifier.updateDocument(new Term("id", String.valueOf(id)), doc);
}
@@ -402,11 +399,9 @@ public class TestIndexWriterDelete exten
private void addDoc(IndexWriter modifier, int id, int value)
throws IOException {
Document doc = new Document();
- doc.add(newField("content", "aaa", Field.Store.NO, Field.Index.ANALYZED));
- doc.add(newField("id", String.valueOf(id), Field.Store.YES,
- Field.Index.NOT_ANALYZED));
- doc.add(newField("value", String.valueOf(value), Field.Store.NO,
- Field.Index.NOT_ANALYZED));
+ doc.add(newField("content", "aaa", TextField.TYPE_UNSTORED));
+ doc.add(newField("id", String.valueOf(id), StringField.TYPE_STORED));
+ doc.add(newField("value", String.valueOf(value), StringField.TYPE_UNSTORED));
modifier.addDocument(doc);
}
@@ -442,10 +437,8 @@ public class TestIndexWriterDelete exten
IndexWriter writer = new IndexWriter(startDir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random, MockTokenizer.WHITESPACE, false)));
for (int i = 0; i < 157; i++) {
Document d = new Document();
- d.add(newField("id", Integer.toString(i), Field.Store.YES,
- Field.Index.NOT_ANALYZED));
- d.add(newField("content", "aaa " + i, Field.Store.NO,
- Field.Index.ANALYZED));
+ d.add(newField("id", Integer.toString(i), StringField.TYPE_STORED));
+ d.add(newField("content", "aaa " + i, TextField.TYPE_UNSTORED));
writer.addDocument(d);
}
writer.close();
@@ -523,10 +516,8 @@ public class TestIndexWriterDelete exten
for (int i = 0; i < 13; i++) {
if (updates) {
Document d = new Document();
- d.add(newField("id", Integer.toString(i), Field.Store.YES,
- Field.Index.NOT_ANALYZED));
- d.add(newField("content", "bbb " + i, Field.Store.NO,
- Field.Index.ANALYZED));
+ d.add(newField("id", Integer.toString(i), StringField.TYPE_STORED));
+ d.add(newField("content", "bbb " + i, TextField.TYPE_UNSTORED));
modifier.updateDocument(new Term("id", Integer.toString(docId)), d);
} else { // deletes
modifier.deleteDocuments(new Term("id", Integer.toString(docId)));
@@ -715,16 +706,14 @@ public class TestIndexWriterDelete exten
dir.failOn(failure.reset());
+ FieldType custom1 = new FieldType();
+ custom1.setStored(true);
for (int i = 0; i < keywords.length; i++) {
Document doc = new Document();
- doc.add(newField("id", keywords[i], Field.Store.YES,
- Field.Index.NOT_ANALYZED));
- doc.add(newField("country", unindexed[i], Field.Store.YES,
- Field.Index.NO));
- doc.add(newField("contents", unstored[i], Field.Store.NO,
- Field.Index.ANALYZED));
- doc.add(newField("city", text[i], Field.Store.YES,
- Field.Index.ANALYZED));
+ doc.add(newField("id", keywords[i], StringField.TYPE_STORED));
+ doc.add(newField("country", unindexed[i], custom1));
+ doc.add(newField("contents", unstored[i], TextField.TYPE_UNSTORED));
+ doc.add(newField("city", text[i], TextField.TYPE_STORED));
modifier.addDocument(doc);
}
// flush (and commit if ac)
@@ -838,16 +827,14 @@ public class TestIndexWriterDelete exten
modifier.commit();
dir.failOn(failure.reset());
+ FieldType custom1 = new FieldType();
+ custom1.setStored(true);
for (int i = 0; i < keywords.length; i++) {
Document doc = new Document();
- doc.add(newField("id", keywords[i], Field.Store.YES,
- Field.Index.NOT_ANALYZED));
- doc.add(newField("country", unindexed[i], Field.Store.YES,
- Field.Index.NO));
- doc.add(newField("contents", unstored[i], Field.Store.NO,
- Field.Index.ANALYZED));
- doc.add(newField("city", text[i], Field.Store.YES,
- Field.Index.ANALYZED));
+ doc.add(newField("id", keywords[i], StringField.TYPE_STORED));
+ doc.add(newField("country", unindexed[i], custom1));
+ doc.add(newField("contents", unstored[i], TextField.TYPE_UNSTORED));
+ doc.add(newField("city", text[i], TextField.TYPE_STORED));
try {
modifier.addDocument(doc);
} catch (IOException io) {
@@ -890,7 +877,7 @@ public class TestIndexWriterDelete exten
Collections.shuffle(ids, random);
for(int id : ids) {
Document doc = new Document();
- doc.add(newField("id", ""+id, Field.Index.NOT_ANALYZED));
+ doc.add(newField("id", ""+id, StringField.TYPE_UNSTORED));
w.addDocument(doc);
}
Collections.shuffle(ids, random);
@@ -924,7 +911,7 @@ public class TestIndexWriterDelete exten
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, analyzer).setRAMBufferSizeMB(1.0).setMaxBufferedDocs(IndexWriterConfig.DISABLE_AUTO_FLUSH).setMaxBufferedDeleteTerms(IndexWriterConfig.DISABLE_AUTO_FLUSH));
w.setInfoStream(VERBOSE ? System.out : null);
Document doc = new Document();
- doc.add(newField("field", "go 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20", Field.Store.NO, Field.Index.ANALYZED));
+ doc.add(newField("field", "go 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20", TextField.TYPE_UNSTORED));
int num = atLeast(3);
for (int iter = 0; iter < num; iter++) {
int count = 0;
@@ -969,7 +956,7 @@ public class TestIndexWriterDelete exten
int count = 0;
while(true) {
Document doc = new Document();
- doc.add(new Field("id", count+"", Field.Store.NO, Field.Index.NOT_ANALYZED));
+ doc.add(new StringField("id", count+""));
final Term delTerm;
if (count == 1010) {
// This is the only delete that applies
@@ -1015,7 +1002,7 @@ public class TestIndexWriterDelete exten
int count = 0;
while(true) {
Document doc = new Document();
- doc.add(new Field("id", count+"", Field.Store.NO, Field.Index.NOT_ANALYZED));
+ doc.add(new StringField("id", count+""));
final Term delTerm;
if (count == 1010) {
// This is the only delete that applies
@@ -1069,8 +1056,8 @@ public class TestIndexWriterDelete exten
w.deleteDocuments(new Term("id", "0"));
}
Document doc = new Document();
- doc.add(newField("id", ""+id, Field.Index.NOT_ANALYZED));
- doc.add(newField("body", sb.toString(), Field.Index.ANALYZED));
+ doc.add(newField("id", ""+id, StringField.TYPE_UNSTORED));
+ doc.add(newField("body", sb.toString(), TextField.TYPE_UNSTORED));
w.updateDocument(new Term("id", ""+id), doc);
docsInSegment.incrementAndGet();
if (dir.fileExists("_0_1.del")) {