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/16 00:03:52 UTC
svn commit: r1158029 [6/15] - in /lucene/dev/branches/fieldtype_conflicted:
lucene/ lucene/contrib/ lucene/contrib/demo/src/java/org/apache/lucene/demo/
lucene/contrib/highlighter/src/java/org/apache/lucene/search/highlight/
lucene/contrib/highlighter/...
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/TestExternalCodecs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/TestExternalCodecs.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/TestExternalCodecs.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/TestExternalCodecs.java Mon Aug 15 22:03:41 2011
@@ -529,13 +529,13 @@ public class TestExternalCodecs extends
w.setInfoStream(VERBOSE ? System.out : null);
Document doc = new Document();
// uses default codec:
- doc.add(newField("field1", "this field uses the standard codec as the test", Field.Store.NO, Field.Index.ANALYZED));
+ doc.add(newField("field1", "this field uses the standard codec as the test", TextField.TYPE_UNSTORED));
// uses pulsing codec:
- Field field2 = newField("field2", "this field uses the pulsing codec as the test", Field.Store.NO, Field.Index.ANALYZED);
+ Field field2 = newField("field2", "this field uses the pulsing codec as the test", TextField.TYPE_UNSTORED);
provider.setFieldCodec(field2.name(), "Pulsing");
doc.add(field2);
- Field idField = newField("id", "", Field.Store.NO, Field.Index.NOT_ANALYZED);
+ Field idField = newField("id", "", StringField.TYPE_UNSTORED);
provider.setFieldCodec(idField.name(), "Pulsing");
doc.add(idField);
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/TestMergeSchedulerExternal.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/TestMergeSchedulerExternal.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/TestMergeSchedulerExternal.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/TestMergeSchedulerExternal.java Mon Aug 15 22:03:41 2011
@@ -33,6 +33,7 @@ import org.apache.lucene.index.MergePoli
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.StringField;
/**
* Holds tests cases to verify external APIs are accessible
@@ -90,7 +91,7 @@ public class TestMergeSchedulerExternal
dir.failOn(new FailOnlyOnMerge());
Document doc = new Document();
- Field idField = newField("id", "", Field.Store.YES, Field.Index.NOT_ANALYZED);
+ Field idField = newField("id", "", StringField.TYPE_STORED);
doc.add(idField);
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/TestSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/TestSearch.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/TestSearch.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/TestSearch.java Mon Aug 15 22:03:41 2011
@@ -93,8 +93,8 @@ public class TestSearch extends LuceneTe
};
for (int j = 0; j < docs.length; j++) {
Document d = new Document();
- d.add(newField("contents", docs[j], Field.Store.YES, Field.Index.ANALYZED));
- d.add(newField("id", ""+j, Field.Index.NOT_ANALYZED_NO_NORMS));
+ d.add(newField("contents", docs[j], TextField.TYPE_STORED));
+ d.add(newField("id", ""+j, StringField.TYPE_UNSTORED));
writer.addDocument(d);
}
writer.close();
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/TestSearchForDuplicates.java Mon Aug 15 22:03:41 2011
@@ -92,8 +92,8 @@ public class TestSearchForDuplicates ext
for (int j = 0; j < MAX_DOCS; j++) {
Document d = new Document();
- d.add(newField(PRIORITY_FIELD, HIGH_PRIORITY, Field.Store.YES, Field.Index.ANALYZED));
- d.add(newField(ID_FIELD, Integer.toString(j), Field.Store.YES, Field.Index.ANALYZED));
+ d.add(newField(PRIORITY_FIELD, HIGH_PRIORITY, TextField.TYPE_STORED));
+ d.add(newField(ID_FIELD, Integer.toString(j), TextField.TYPE_STORED));
writer.addDocument(d);
}
writer.close();
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/analysis/TestCachingTokenFilter.java Mon Aug 15 22:03:41 2011
@@ -23,8 +23,7 @@ import java.io.IOException;
import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.document.Field.TermVector;
+import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.MultiFields;
import org.apache.lucene.index.DocsAndPositionsEnum;
@@ -60,7 +59,7 @@ public class TestCachingTokenFilter exte
stream = new CachingTokenFilter(stream);
- doc.add(new Field("preanalyzed", stream, TermVector.NO));
+ doc.add(new TextField("preanalyzed", stream));
// 1) we consume all tokens twice before we add the doc to the index
checkTokens(stream);
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/document/TestBinaryDocument.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/document/TestBinaryDocument.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/document/TestBinaryDocument.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/document/TestBinaryDocument.java Mon Aug 15 22:03:41 2011
@@ -2,7 +2,13 @@ package org.apache.lucene.document;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.document.BinaryField;
+import org.apache.lucene.document.CompressionTools;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field;
+import org.apache.lucene.document.FieldType;
import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.store.Directory;
@@ -34,8 +40,10 @@ public class TestBinaryDocument extends
public void testBinaryFieldInIndex()
throws Exception
{
- Fieldable binaryFldStored = new Field("binaryStored", binaryValStored.getBytes());
- Fieldable stringFldStored = new Field("stringStored", binaryValStored, Field.Store.YES, Field.Index.NO, Field.TermVector.NO);
+ FieldType ft = new FieldType();
+ ft.setStored(true);
+ IndexableField binaryFldStored = new BinaryField("binaryStored", binaryValStored.getBytes());
+ IndexableField stringFldStored = new Field("stringStored", ft, binaryValStored);
Document doc = new Document();
@@ -77,8 +85,8 @@ public class TestBinaryDocument extends
}
public void testCompressionTools() throws Exception {
- Fieldable binaryFldCompressed = new Field("binaryCompressed", CompressionTools.compress(binaryValCompressed.getBytes()));
- Fieldable stringFldCompressed = new Field("stringCompressed", CompressionTools.compressString(binaryValCompressed));
+ IndexableField binaryFldCompressed = new BinaryField("binaryCompressed", CompressionTools.compress(binaryValCompressed.getBytes()));
+ IndexableField stringFldCompressed = new BinaryField("stringCompressed", CompressionTools.compressString(binaryValCompressed));
Document doc = new Document();
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/document/TestDateTools.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/document/TestDateTools.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/document/TestDateTools.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/document/TestDateTools.java Mon Aug 15 22:03:41 2011
@@ -8,6 +8,7 @@ import java.util.GregorianCalendar;
import java.util.TimeZone;
import java.util.Locale;
+import org.apache.lucene.document.DateTools;
import org.apache.lucene.util.LuceneTestCase;
/**
@@ -196,4 +197,4 @@ public class TestDateTools extends Lucen
}
}
-}
\ No newline at end of file
+}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/document/TestDocument.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/document/TestDocument.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/document/TestDocument.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/document/TestDocument.java Mon Aug 15 22:03:41 2011
@@ -1,6 +1,13 @@
package org.apache.lucene.document;
+import org.apache.lucene.document.BinaryField;
+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.index.IndexReader;
+import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.RandomIndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.IndexSearcher;
@@ -37,20 +44,22 @@ public class TestDocument extends Lucene
public void testBinaryField() throws Exception {
Document doc = new Document();
- Fieldable stringFld = new Field("string", binaryVal, Field.Store.YES,
- Field.Index.NO);
- Fieldable binaryFld = new Field("binary", binaryVal.getBytes());
- Fieldable binaryFld2 = new Field("binary", binaryVal2.getBytes());
+
+ FieldType ft = new FieldType();
+ ft.setStored(true);
+ IndexableField stringFld = new Field("string", ft, binaryVal);
+ IndexableField binaryFld = new BinaryField("binary", binaryVal.getBytes());
+ IndexableField binaryFld2 = new BinaryField("binary", binaryVal2.getBytes());
doc.add(stringFld);
doc.add(binaryFld);
assertEquals(2, doc.fields.size());
- assertTrue(binaryFld.isBinary());
- assertTrue(binaryFld.isStored());
- assertFalse(binaryFld.isIndexed());
- assertFalse(binaryFld.isTokenized());
+ assertTrue(binaryFld.binaryValue(null) != null);
+ assertTrue(binaryFld.stored());
+ assertFalse(binaryFld.indexed());
+ assertFalse(binaryFld.tokenized());
String binaryTest = new String(doc.getBinaryValue("binary"));
assertTrue(binaryTest.equals(binaryVal));
@@ -115,19 +124,22 @@ public class TestDocument extends Lucene
}
public void testConstructorExceptions() {
- new Field("name", "value", Field.Store.YES, Field.Index.NO); // okay
- new Field("name", "value", Field.Store.NO, Field.Index.NOT_ANALYZED); // okay
+ FieldType ft = new FieldType();
+ ft.setStored(true);
+ new Field("name", ft, "value"); // okay
+ new StringField("name", "value"); // okay
try {
- new Field("name", "value", Field.Store.NO, Field.Index.NO);
+ new Field("name", new FieldType(), "value");
fail();
} catch (IllegalArgumentException e) {
// expected exception
}
- new Field("name", "value", Field.Store.YES, Field.Index.NO,
- Field.TermVector.NO); // okay
+ new Field("name", ft, "value"); // okay
try {
- new Field("name", "value", Field.Store.YES, Field.Index.NO,
- Field.TermVector.YES);
+ FieldType ft2 = new FieldType();
+ ft2.setStored(true);
+ ft2.setStoreTermVectors(true);
+ new Field("name", ft2, "value");
fail();
} catch (IllegalArgumentException e) {
// expected exception
@@ -174,28 +186,26 @@ public class TestDocument extends Lucene
private Document makeDocumentWithFields() {
Document doc = new Document();
- doc.add(new Field("keyword", "test1", Field.Store.YES,
- Field.Index.NOT_ANALYZED));
- doc.add(new Field("keyword", "test2", Field.Store.YES,
- Field.Index.NOT_ANALYZED));
- doc.add(new Field("text", "test1", Field.Store.YES, Field.Index.ANALYZED));
- doc.add(new Field("text", "test2", Field.Store.YES, Field.Index.ANALYZED));
- doc.add(new Field("unindexed", "test1", Field.Store.YES, Field.Index.NO));
- doc.add(new Field("unindexed", "test2", Field.Store.YES, Field.Index.NO));
+ FieldType stored = new FieldType();
+ stored.setStored(true);
+ doc.add(new Field("keyword", StringField.TYPE_STORED, "test1"));
+ doc.add(new Field("keyword", StringField.TYPE_STORED, "test2"));
+ doc.add(new Field("text", TextField.TYPE_STORED, "test1"));
+ doc.add(new Field("text", TextField.TYPE_STORED, "test2"));
+ doc.add(new Field("unindexed", stored, "test1"));
+ doc.add(new Field("unindexed", stored, "test2"));
doc
- .add(new Field("unstored", "test1", Field.Store.NO,
- Field.Index.ANALYZED));
+ .add(new TextField("unstored", "test1"));
doc
- .add(new Field("unstored", "test2", Field.Store.NO,
- Field.Index.ANALYZED));
+ .add(new TextField("unstored", "test2"));
return doc;
}
private void doAssert(Document doc, boolean fromIndex) {
- String[] keywordFieldValues = doc.getValues("keyword");
- String[] textFieldValues = doc.getValues("text");
- String[] unindexedFieldValues = doc.getValues("unindexed");
- String[] unstoredFieldValues = doc.getValues("unstored");
+ IndexableField[] keywordFieldValues = doc.getFields("keyword");
+ IndexableField[] textFieldValues = doc.getFields("text");
+ IndexableField[] unindexedFieldValues = doc.getFields("unindexed");
+ IndexableField[] unstoredFieldValues = doc.getFields("unstored");
assertTrue(keywordFieldValues.length == 2);
assertTrue(textFieldValues.length == 2);
@@ -206,28 +216,26 @@ public class TestDocument extends Lucene
assertTrue(unstoredFieldValues.length == 2);
}
- assertTrue(keywordFieldValues[0].equals("test1"));
- assertTrue(keywordFieldValues[1].equals("test2"));
- assertTrue(textFieldValues[0].equals("test1"));
- assertTrue(textFieldValues[1].equals("test2"));
- assertTrue(unindexedFieldValues[0].equals("test1"));
- assertTrue(unindexedFieldValues[1].equals("test2"));
+ assertTrue(keywordFieldValues[0].stringValue().equals("test1"));
+ assertTrue(keywordFieldValues[1].stringValue().equals("test2"));
+ assertTrue(textFieldValues[0].stringValue().equals("test1"));
+ assertTrue(textFieldValues[1].stringValue().equals("test2"));
+ assertTrue(unindexedFieldValues[0].stringValue().equals("test1"));
+ assertTrue(unindexedFieldValues[1].stringValue().equals("test2"));
// this test cannot work for documents retrieved from the index
// since unstored fields will obviously not be returned
if (!fromIndex) {
- assertTrue(unstoredFieldValues[0].equals("test1"));
- assertTrue(unstoredFieldValues[1].equals("test2"));
+ assertTrue(unstoredFieldValues[0].stringValue().equals("test1"));
+ assertTrue(unstoredFieldValues[1].stringValue().equals("test2"));
}
}
public void testFieldSetValue() throws Exception {
- Field field = new Field("id", "id1", Field.Store.YES,
- Field.Index.NOT_ANALYZED);
+ Field field = new Field("id", StringField.TYPE_STORED, "id1");
Document doc = new Document();
doc.add(field);
- doc.add(new Field("keyword", "test", Field.Store.YES,
- Field.Index.NOT_ANALYZED));
+ doc.add(new Field("keyword", StringField.TYPE_STORED, "test"));
Directory dir = newDirectory();
RandomIndexWriter writer = new RandomIndexWriter(random, dir);
@@ -248,7 +256,7 @@ public class TestDocument extends Lucene
int result = 0;
for (int i = 0; i < 3; i++) {
Document doc2 = searcher.doc(hits[i].doc);
- Field f = doc2.getField("id");
+ Field f = (Field) doc2.getField("id");
if (f.stringValue().equals("id1")) result |= 1;
else if (f.stringValue().equals("id2")) result |= 2;
else if (f.stringValue().equals("id3")) result |= 4;
@@ -262,9 +270,8 @@ public class TestDocument extends Lucene
}
public void testFieldSetValueChangeBinary() {
- Field field1 = new Field("field1", new byte[0]);
- Field field2 = new Field("field2", "", Field.Store.YES,
- Field.Index.ANALYZED);
+ Field field1 = new BinaryField("field1", new byte[0]);
+ Field field2 = new Field("field2", TextField.TYPE_STORED, "");
try {
field1.setValue("abc");
fail("did not hit expected exception");
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/Test2BTerms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/Test2BTerms.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/Test2BTerms.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/Test2BTerms.java Mon Aug 15 22:03:41 2011
@@ -177,9 +177,18 @@ public class Test2BTerms extends LuceneT
Document doc = new Document();
final MyTokenStream ts = new MyTokenStream(random, TERMS_PER_DOC);
+<<<<<<<
Field field = new Field("field", ts);
field.setIndexOptions(IndexOptions.DOCS_ONLY);
field.setOmitNorms(true);
+=======
+
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ customType.setOmitTermFreqAndPositions(true);
+ customType.setOmitNorms(true);
+ Field field = new Field("field", customType, ts);
+>>>>>>>
doc.add(field);
//w.setInfoStream(System.out);
final int numDocs = (int) (TERM_COUNT/TERMS_PER_DOC);
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestAddIndexes.java Mon Aug 15 22:03:41 2011
@@ -25,9 +25,9 @@ import java.util.List;
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.Field.TermVector;
+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.index.codecs.CodecProvider;
import org.apache.lucene.index.codecs.mocksep.MockSepCodec;
@@ -165,11 +165,12 @@ public class TestAddIndexes extends Luce
// Adds 10 docs, then replaces them with another 10
// docs, so 10 pending deletes:
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setTokenized(false);
for (int i = 0; i < 20; i++) {
Document doc = new Document();
- doc.add(newField("id", "" + (i % 10), Field.Store.NO, Field.Index.NOT_ANALYZED));
- doc.add(newField("content", "bbb " + i, Field.Store.NO,
- Field.Index.ANALYZED));
+ doc.add(newField("id", "" + (i % 10), customType));
+ doc.add(newField("content", "bbb " + i, TextField.TYPE_UNSTORED));
writer.updateDocument(new Term("id", "" + (i%10)), doc);
}
// Deletes one of the 10 added docs, leaving 9:
@@ -201,10 +202,12 @@ public class TestAddIndexes extends Luce
// Adds 10 docs, then replaces them with another 10
// docs, so 10 pending deletes:
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setTokenized(false);
for (int i = 0; i < 20; i++) {
Document doc = new Document();
- doc.add(newField("id", "" + (i % 10), Field.Store.NO, Field.Index.NOT_ANALYZED));
- doc.add(newField("content", "bbb " + i, Field.Store.NO, Field.Index.ANALYZED));
+ doc.add(newField("id", "" + (i % 10), customType));
+ doc.add(newField("content", "bbb " + i, TextField.TYPE_UNSTORED));
writer.updateDocument(new Term("id", "" + (i%10)), doc);
}
@@ -239,11 +242,12 @@ public class TestAddIndexes extends Luce
// Adds 10 docs, then replaces them with another 10
// docs, so 10 pending deletes:
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setTokenized(false);
for (int i = 0; i < 20; i++) {
Document doc = new Document();
- doc.add(newField("id", "" + (i % 10), Field.Store.NO, Field.Index.NOT_ANALYZED));
- doc.add(newField("content", "bbb " + i, Field.Store.NO,
- Field.Index.ANALYZED));
+ doc.add(newField("id", "" + (i % 10), customType));
+ doc.add(newField("content", "bbb " + i, TextField.TYPE_UNSTORED));
writer.updateDocument(new Term("id", "" + (i%10)), doc);
}
@@ -503,8 +507,7 @@ public class TestAddIndexes extends Luce
private void addDocs(IndexWriter writer, int numDocs) throws IOException {
for (int i = 0; i < numDocs; i++) {
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);
}
}
@@ -512,8 +515,7 @@ public class TestAddIndexes extends Luce
private void addDocs2(IndexWriter writer, int numDocs) throws IOException {
for (int i = 0; i < numDocs; i++) {
Document doc = new Document();
- doc.add(newField("content", "bbb", Field.Store.NO,
- Field.Index.ANALYZED));
+ doc.add(newField("content", "bbb", TextField.TYPE_UNSTORED));
writer.addDocument(doc);
}
}
@@ -582,20 +584,22 @@ public class TestAddIndexes extends Luce
.setMaxBufferedDocs(5).setMergePolicy(lmp));
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_UNSTORED);
+ customType.setStored(true);
+ customType.setStoreTermVectors(true);
+ customType.setStoreTermVectorPositions(true);
+ customType.setStoreTermVectorOffsets(true);
+ doc.add(newField("content", "aaa bbb ccc ddd eee fff ggg hhh iii", customType));
for(int i=0;i<60;i++)
writer.addDocument(doc);
Document doc2 = new Document();
- doc2.add(newField("content", "aaa bbb ccc ddd eee fff ggg hhh iii", Field.Store.YES,
- Field.Index.NO));
- doc2.add(newField("content", "aaa bbb ccc ddd eee fff ggg hhh iii", Field.Store.YES,
- Field.Index.NO));
- doc2.add(newField("content", "aaa bbb ccc ddd eee fff ggg hhh iii", Field.Store.YES,
- Field.Index.NO));
- doc2.add(newField("content", "aaa bbb ccc ddd eee fff ggg hhh iii", Field.Store.YES,
- Field.Index.NO));
+ FieldType customType2 = new FieldType();
+ customType2.setStored(true);
+ doc2.add(newField("content", "aaa bbb ccc ddd eee fff ggg hhh iii", customType2));
+ doc2.add(newField("content", "aaa bbb ccc ddd eee fff ggg hhh iii", customType2));
+ doc2.add(newField("content", "aaa bbb ccc ddd eee fff ggg hhh iii", customType2));
+ doc2.add(newField("content", "aaa bbb ccc ddd eee fff ggg hhh iii", customType2));
for(int i=0;i<10;i++)
writer.addDocument(doc2);
writer.close();
@@ -619,7 +623,7 @@ public class TestAddIndexes extends Luce
private 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);
}
@@ -944,7 +948,7 @@ public class TestAddIndexes extends Luce
IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random));
IndexWriter writer = new IndexWriter(dirs[i], conf);
Document doc = new Document();
- doc.add(new Field("id", "myid", Store.NO, Index.NOT_ANALYZED_NO_NORMS));
+ doc.add(new StringField("id", "myid"));
writer.addDocument(doc);
writer.close();
}
@@ -973,8 +977,10 @@ public class TestAddIndexes extends Luce
private void addDocs3(IndexWriter writer, int numDocs) throws IOException {
for (int i = 0; i < numDocs; i++) {
Document doc = new Document();
- doc.add(newField("content", "aaa", Field.Store.NO, Field.Index.ANALYZED));
- doc.add(newField("id", "" + i, Field.Store.YES, Field.Index.ANALYZED));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ doc.add(newField("content", "aaa", TextField.TYPE_UNSTORED));
+ doc.add(newField("id", "" + i, customType));
writer.addDocument(doc);
}
}
@@ -1061,7 +1067,10 @@ public class TestAddIndexes extends Luce
dirs[i] = new RAMDirectory();
IndexWriter w = new IndexWriter(dirs[i], new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)));
Document d = new Document();
- d.add(new Field("c", "v", Store.YES, Index.ANALYZED, TermVector.YES));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ customType.setStoreTermVectors(true);
+ d.add(new Field("c", customType, "v"));
w.addDocument(d);
w.close();
}
@@ -1099,10 +1108,12 @@ public class TestAddIndexes extends Luce
new MockAnalyzer(random)).setMergePolicy(lmp2);
IndexWriter w2 = new IndexWriter(src, conf2);
Document doc = new Document();
- doc.add(new Field("c", "some text", Store.YES, Index.ANALYZED));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ doc.add(new Field("c", customType, "some text"));
w2.addDocument(doc);
doc = new Document();
- doc.add(new Field("d", "delete", Store.NO, Index.NOT_ANALYZED_NO_NORMS));
+ doc.add(new StringField("d", "delete"));
w2.addDocument(doc);
w2.commit();
w2.deleteDocuments(new Term("d", "delete"));
@@ -1152,7 +1163,9 @@ public class TestAddIndexes extends Luce
conf.setCodecProvider(provider);
IndexWriter w = new IndexWriter(toAdd, conf);
Document doc = new Document();
- doc.add(newField("foo", "bar", Index.NOT_ANALYZED));
+ FieldType customType = new FieldType();
+ customType.setIndexed(true);
+ doc.add(newField("foo", "bar", customType));
w.addDocument(doc);
w.close();
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestAtomicUpdate.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestAtomicUpdate.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestAtomicUpdate.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestAtomicUpdate.java Mon Aug 15 22:03:41 2011
@@ -93,10 +93,12 @@ public class TestAtomicUpdate extends Lu
@Override
public void doWork() throws Exception {
// Update all 100 docs...
+ FieldType customType = new FieldType(StringField.TYPE_UNSTORED);
+ customType.setStored(true);
for(int i=0; i<100; i++) {
Document d = new Document();
- d.add(new Field("id", Integer.toString(i), Field.Store.YES, Field.Index.NOT_ANALYZED));
- d.add(new Field("contents", English.intToEnglish(i+10*count), Field.Store.NO, Field.Index.ANALYZED));
+ d.add(new Field("id", customType, Integer.toString(i)));
+ d.add(new TextField("contents", English.intToEnglish(i+10*count)));
writer.updateDocument(new Term("id", Integer.toString(i)), d);
}
}
@@ -134,10 +136,12 @@ public class TestAtomicUpdate extends Lu
writer.setInfoStream(VERBOSE ? System.out : null);
// Establish a base index of 100 docs:
+ FieldType customType = new FieldType(StringField.TYPE_UNSTORED);
+ customType.setStored(true);
for(int i=0;i<100;i++) {
Document d = new Document();
- d.add(newField("id", Integer.toString(i), Field.Store.YES, Field.Index.NOT_ANALYZED));
- d.add(newField("contents", English.intToEnglish(i), Field.Store.NO, Field.Index.ANALYZED));
+ d.add(newField("id", Integer.toString(i), customType));
+ d.add(newField("contents", English.intToEnglish(i), TextField.TYPE_UNSTORED));
if ((i-1)%7 == 0) {
writer.commit();
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java Mon Aug 15 22:03:41 2011
@@ -29,9 +29,13 @@ import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
-import org.apache.lucene.document.Fieldable;
+import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.NumericField;
+<<<<<<<
import org.apache.lucene.index.FieldInfo.IndexOptions;
+=======
+import org.apache.lucene.document.TextField;
+>>>>>>>
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.search.DefaultSimilarity;
import org.apache.lucene.search.DocIdSetIterator;
@@ -288,11 +292,11 @@ public class TestBackwardsCompatibility
for(int i=0;i<35;i++) {
if (liveDocs.get(i)) {
Document d = reader.document(i);
- List<Fieldable> fields = d.getFields();
+ List<IndexableField> fields = d.getFields();
if (d.getField("content3") == null) {
final int numFields = 5;
assertEquals(numFields, fields.size());
- Field f = d.getField("id");
+ IndexableField f = d.getField("id");
assertEquals(""+i, f.stringValue());
f = d.getField("utf8");
@@ -594,12 +598,20 @@ public class TestBackwardsCompatibility
private void addDoc(IndexWriter writer, int id) throws IOException
{
Document doc = new Document();
- doc.add(new Field("content", "aaa", Field.Store.NO, Field.Index.ANALYZED));
- doc.add(new Field("id", Integer.toString(id), Field.Store.YES, Field.Index.NOT_ANALYZED));
- doc.add(new Field("autf8", "Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
- doc.add(new Field("utf8", "Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
- doc.add(new Field("content2", "here is more content with aaa aaa aaa", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
- doc.add(new Field("fie\u2C77ld", "field with non-ascii name", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
+ doc.add(new TextField("content", "aaa"));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ customType.setTokenized(false);
+ doc.add(new Field("id", customType, Integer.toString(id)));
+ FieldType customType2 = new FieldType(TextField.TYPE_UNSTORED);
+ customType2.setStored(true);
+ customType2.setStoreTermVectors(true);
+ customType2.setStoreTermVectorPositions(true);
+ customType2.setStoreTermVectorOffsets(true);
+ doc.add(new Field("autf8", customType2, "Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd"));
+ doc.add(new Field("utf8", customType2, "Lu\uD834\uDD1Ece\uD834\uDD60ne \u0000 \u2620 ab\ud917\udc17cd"));
+ doc.add(new Field("content2", customType2, "here is more content with aaa aaa aaa"));
+ doc.add(new Field("fie\u2C77ld", customType2, "field with non-ascii name"));
// add numeric fields, to test if flex preserves encoding
doc.add(new NumericField("trieInt", 4).setIntValue(id));
doc.add(new NumericField("trieLong", 4).setLongValue(id));
@@ -608,11 +620,25 @@ public class TestBackwardsCompatibility
private void addNoProxDoc(IndexWriter writer) throws IOException {
Document doc = new Document();
+<<<<<<<
Field f = new Field("content3", "aaa", Field.Store.YES, Field.Index.ANALYZED);
f.setIndexOptions(IndexOptions.DOCS_ONLY);
+=======
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ customType.setOmitTermFreqAndPositions(true);
+ Field f = new Field("content3", customType, "aaa");
+>>>>>>>
doc.add(f);
+<<<<<<<
f = new Field("content4", "aaa", Field.Store.YES, Field.Index.NO);
f.setIndexOptions(IndexOptions.DOCS_ONLY);
+=======
+ FieldType customType2 = new FieldType();
+ customType2.setStored(true);
+ customType2.setOmitTermFreqAndPositions(true);
+ f = new Field("content4", customType2, "aaa");
+>>>>>>>
doc.add(f);
writer.addDocument(doc);
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestBinaryTerms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestBinaryTerms.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestBinaryTerms.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestBinaryTerms.java Mon Aug 15 22:03:41 2011
@@ -21,6 +21,8 @@ import java.io.IOException;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.TextField;
import org.apache.lucene.index.codecs.CodecProvider;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.TermQuery;
@@ -47,8 +49,10 @@ public class TestBinaryTerms extends Luc
bytes.bytes[1] = (byte) (255 - i);
bytes.length = 2;
Document doc = new Document();
- doc.add(new Field("id", "" + i, Field.Store.YES, Field.Index.NO));
- doc.add(new Field("bytes", tokenStream));
+ FieldType customType = new FieldType();
+ customType.setStored(true);
+ doc.add(new Field("id", customType, "" + i));
+ doc.add(new TextField("bytes", tokenStream));
iw.addDocument(doc);
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestCheckIndex.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestCheckIndex.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestCheckIndex.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestCheckIndex.java Mon Aug 15 22:03:41 2011
@@ -28,6 +28,8 @@ import org.apache.lucene.store.Directory
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.TextField;
import org.apache.lucene.util.Constants;
public class TestCheckIndex extends LuceneTestCase {
@@ -36,7 +38,12 @@ public class TestCheckIndex extends Luce
Directory dir = newDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMaxBufferedDocs(2));
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_UNSTORED);
+ customType.setStored(true);
+ 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);
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestCodecs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestCodecs.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestCodecs.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestCodecs.java Mon Aug 15 22:03:41 2011
@@ -24,8 +24,13 @@ import java.util.HashSet;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+<<<<<<<
import org.apache.lucene.document.Field.Store;
import org.apache.lucene.index.FieldInfo.IndexOptions;
+=======
+import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.TextField;
+>>>>>>>
import org.apache.lucene.index.codecs.CodecProvider;
import org.apache.lucene.index.codecs.FieldsConsumer;
import org.apache.lucene.index.codecs.FieldsProducer;
@@ -342,7 +347,9 @@ public class TestCodecs extends LuceneTe
pq.add(new Term("content", "ccc"));
final Document doc = new Document();
- doc.add(newField("content", "aaa bbb ccc ddd", Store.NO, Field.Index.ANALYZED_NO_NORMS));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setOmitNorms(true);
+ doc.add(newField("content", "aaa bbb ccc ddd", customType));
// add document and force commit for creating a first segment
writer.addDocument(doc);
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java Mon Aug 15 22:03:41 2011
@@ -21,6 +21,8 @@ import org.apache.lucene.store.MockDirec
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.util.LuceneTestCase;
@@ -75,7 +77,10 @@ public class TestConcurrentMergeSchedule
IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMaxBufferedDocs(2));
writer.setInfoStream(VERBOSE ? System.out : null);
Document doc = new Document();
- Field idField = newField("id", "", Field.Store.YES, Field.Index.NOT_ANALYZED);
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ customType.setTokenized(false);
+ Field idField = newField("id", "", customType);
doc.add(idField);
int extraCount = 0;
@@ -135,7 +140,10 @@ public class TestConcurrentMergeSchedule
writer.setInfoStream(VERBOSE ? System.out : null);
Document doc = new Document();
- Field idField = newField("id", "", Field.Store.YES, Field.Index.NOT_ANALYZED);
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ customType.setTokenized(false);
+ Field idField = newField("id", "", customType);
doc.add(idField);
for(int i=0;i<10;i++) {
if (VERBOSE) {
@@ -180,7 +188,7 @@ public class TestConcurrentMergeSchedule
for(int j=0;j<21;j++) {
Document doc = new Document();
- doc.add(newField("content", "a b c", Field.Store.NO, Field.Index.ANALYZED));
+ doc.add(newField("content", "a b c", TextField.TYPE_UNSTORED));
writer.addDocument(doc);
}
@@ -202,7 +210,10 @@ public class TestConcurrentMergeSchedule
public void testNoWaitClose() throws IOException {
MockDirectoryWrapper directory = newDirectory();
Document doc = new Document();
- Field idField = newField("id", "", Field.Store.YES, Field.Index.NOT_ANALYZED);
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ customType.setTokenized(false);
+ Field idField = newField("id", "", customType);
doc.add(idField);
IndexWriter writer = new IndexWriter(
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestConsistentFieldNumbers.java Mon Aug 15 22:03:41 2011
@@ -20,11 +20,11 @@ package org.apache.lucene.index;
import java.io.IOException;
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.Field.Index;
-import org.apache.lucene.document.Field.Store;
-import org.apache.lucene.document.Field.TermVector;
+import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.TextField;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.junit.Test;
@@ -38,8 +38,11 @@ public class TestConsistentFieldNumbers
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMergePolicy(NoMergePolicy.COMPOUND_FILES));
Document d1 = new Document();
- d1.add(new Field("f1", "first field", Store.YES, Index.ANALYZED, TermVector.NO));
- d1.add(new Field("f2", "second field", Store.YES, Index.ANALYZED, TermVector.NO));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ customType.setTokenized(false);
+ d1.add(new Field("f1", customType, "first field"));
+ d1.add(new Field("f2", customType, "second field"));
writer.addDocument(d1);
if (i == 1) {
@@ -50,10 +53,13 @@ public class TestConsistentFieldNumbers
}
Document d2 = new Document();
- d2.add(new Field("f2", "second field", Store.YES, Index.ANALYZED, TermVector.NO));
- d2.add(new Field("f1", "first field", Store.YES, Index.ANALYZED, TermVector.YES));
- d2.add(new Field("f3", "third field", Store.YES, Index.ANALYZED, TermVector.NO));
- d2.add(new Field("f4", "fourth field", Store.YES, Index.ANALYZED, TermVector.NO));
+ FieldType customType2 = new FieldType(TextField.TYPE_UNSTORED);
+ customType2.setStored(true);
+ customType2.setStoreTermVectors(true);
+ d2.add(new TextField("f2", "second field"));
+ d2.add(new Field("f1", customType2, "first field"));
+ d2.add(new TextField("f3", "third field"));
+ d2.add(new TextField("f4", "fourth field"));
writer.addDocument(d2);
writer.close();
@@ -99,18 +105,23 @@ public class TestConsistentFieldNumbers
IndexWriter writer = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMergePolicy(NoMergePolicy.COMPOUND_FILES));
Document d1 = new Document();
- d1.add(new Field("f1", "first field", Store.YES, Index.ANALYZED, TermVector.NO));
- d1.add(new Field("f2", "second field", Store.YES, Index.ANALYZED, TermVector.NO));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ d1.add(new Field("f1", customType, "first field"));
+ d1.add(new Field("f2", customType, "second field"));
writer.addDocument(d1);
writer.close();
writer = new IndexWriter(dir2, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMergePolicy(NoMergePolicy.COMPOUND_FILES));
Document d2 = new Document();
- d2.add(new Field("f2", "second field", Store.YES, Index.ANALYZED, TermVector.NO));
- d2.add(new Field("f1", "first field", Store.YES, Index.ANALYZED, TermVector.YES));
- d2.add(new Field("f3", "third field", Store.YES, Index.ANALYZED, TermVector.NO));
- d2.add(new Field("f4", "fourth field", Store.YES, Index.ANALYZED, TermVector.NO));
+ FieldType customType2 = new FieldType(TextField.TYPE_UNSTORED);
+ customType2.setStored(true);
+ customType2.setStoreTermVectors(true);
+ d2.add(new Field("f2", customType, "second field"));
+ d2.add(new Field("f1", customType2, "first field"));
+ d2.add(new Field("f3", customType, "third field"));
+ d2.add(new Field("f4", customType, "fourth field"));
writer.addDocument(d2);
writer.close();
@@ -156,6 +167,8 @@ public class TestConsistentFieldNumbers
public void testFieldNumberGaps() throws IOException {
int numIters = atLeast(13);
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
for (int i = 0; i < numIters; i++) {
Directory dir = newDirectory();
{
@@ -163,10 +176,8 @@ public class TestConsistentFieldNumbers
TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMergePolicy(
NoMergePolicy.NO_COMPOUND_FILES));
Document d = new Document();
- d.add(new Field("f1", "d1 first field", Store.YES, Index.ANALYZED,
- TermVector.NO));
- d.add(new Field("f2", "d1 second field", Store.YES, Index.ANALYZED,
- TermVector.NO));
+ d.add(new Field("f1", customType, "d1 first field"));
+ d.add(new Field("f2", customType, "d1 second field"));
writer.addDocument(d);
writer.close();
SegmentInfos sis = new SegmentInfos();
@@ -185,9 +196,8 @@ public class TestConsistentFieldNumbers
random.nextBoolean() ? NoMergePolicy.NO_COMPOUND_FILES
: NoMergePolicy.COMPOUND_FILES));
Document d = new Document();
- d.add(new Field("f1", "d2 first field", Store.YES, Index.ANALYZED,
- TermVector.NO));
- d.add(new Field("f3", new byte[] { 1, 2, 3 }));
+ d.add(new Field("f1", customType, "d2 first field"));
+ d.add(new BinaryField("f3", new byte[] { 1, 2, 3 }));
writer.addDocument(d);
writer.close();
SegmentInfos sis = new SegmentInfos();
@@ -210,11 +220,9 @@ public class TestConsistentFieldNumbers
random.nextBoolean() ? NoMergePolicy.NO_COMPOUND_FILES
: NoMergePolicy.COMPOUND_FILES));
Document d = new Document();
- d.add(new Field("f1", "d3 first field", Store.YES, Index.ANALYZED,
- TermVector.NO));
- d.add(new Field("f2", "d3 second field", Store.YES, Index.ANALYZED,
- TermVector.NO));
- d.add(new Field("f3", new byte[] { 1, 2, 3, 4, 5 }));
+ d.add(new Field("f1", customType, "d3 first field"));
+ d.add(new Field("f2", customType, "d3 second field"));
+ d.add(new BinaryField("f3", new byte[] { 1, 2, 3, 4, 5 }));
writer.addDocument(d);
writer.close();
SegmentInfos sis = new SegmentInfos();
@@ -303,10 +311,10 @@ public class TestConsistentFieldNumbers
for (FieldInfo fi : fis) {
Field expected = getField(Integer.parseInt(fi.name));
- assertEquals(expected.isIndexed(), fi.isIndexed);
- assertEquals(expected.isTermVectorStored(), fi.storeTermVector);
- assertEquals(expected.isStorePositionWithTermVector(), fi.storePositionWithTermVector);
- assertEquals(expected.isStoreOffsetWithTermVector(), fi.storeOffsetWithTermVector);
+ assertEquals(expected.indexed(), fi.isIndexed);
+ assertEquals(expected.storeTermVectors(), fi.storeTermVector);
+ assertEquals(expected.storeTermVectorPositions(), fi.storePositionWithTermVector);
+ assertEquals(expected.storeTermVectorOffsets(), fi.storeOffsetWithTermVector);
}
}
@@ -316,23 +324,99 @@ public class TestConsistentFieldNumbers
private Field getField(int number) {
int mode = number % 16;
String fieldName = "" + number;
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+
+ FieldType customType2 = new FieldType(TextField.TYPE_UNSTORED);
+ customType2.setStored(true);
+ customType2.setTokenized(false);
+
+ FieldType customType3 = new FieldType(TextField.TYPE_UNSTORED);
+ customType3.setTokenized(false);
+
+ FieldType customType4 = new FieldType(TextField.TYPE_UNSTORED);
+ customType4.setTokenized(false);
+ customType4.setStored(false);
+ customType4.setStoreTermVectors(true);
+ customType4.setStoreTermVectorOffsets(true);
+
+ FieldType customType5 = new FieldType(TextField.TYPE_UNSTORED);
+ customType5.setStoreTermVectors(true);
+ customType5.setStoreTermVectorOffsets(true);
+
+ FieldType customType6 = new FieldType(TextField.TYPE_UNSTORED);
+ customType6.setTokenized(false);
+ customType6.setStored(true);
+ customType6.setStoreTermVectors(true);
+ customType6.setStoreTermVectorOffsets(true);
+
+ FieldType customType7 = new FieldType(TextField.TYPE_UNSTORED);
+ customType7.setTokenized(false);
+ customType7.setStoreTermVectors(true);
+ customType7.setStoreTermVectorOffsets(true);
+
+ FieldType customType8 = new FieldType(TextField.TYPE_UNSTORED);
+ customType8.setTokenized(false);
+ customType8.setStored(true);
+ customType8.setStoreTermVectors(true);
+ customType8.setStoreTermVectorPositions(true);
+
+ FieldType customType9 = new FieldType(TextField.TYPE_UNSTORED);
+ customType9.setStoreTermVectors(true);
+ customType9.setStoreTermVectorPositions(true);
+
+ FieldType customType10 = new FieldType(TextField.TYPE_UNSTORED);
+ customType10.setTokenized(false);
+ customType10.setStored(true);
+ customType10.setStoreTermVectors(true);
+ customType10.setStoreTermVectorPositions(true);
+
+ FieldType customType11 = new FieldType(TextField.TYPE_UNSTORED);
+ customType11.setTokenized(false);
+ customType11.setStoreTermVectors(true);
+ customType11.setStoreTermVectorPositions(true);
+
+ FieldType customType12 = new FieldType(TextField.TYPE_UNSTORED);
+ customType12.setStored(true);
+ customType12.setStoreTermVectors(true);
+ customType12.setStoreTermVectorOffsets(true);
+ customType12.setStoreTermVectorPositions(true);
+
+ FieldType customType13 = new FieldType(TextField.TYPE_UNSTORED);
+ customType13.setStoreTermVectors(true);
+ customType13.setStoreTermVectorOffsets(true);
+ customType13.setStoreTermVectorPositions(true);
+
+ FieldType customType14 = new FieldType(TextField.TYPE_UNSTORED);
+ customType14.setStored(true);
+ customType14.setTokenized(false);
+ customType14.setStoreTermVectors(true);
+ customType14.setStoreTermVectorOffsets(true);
+ customType14.setStoreTermVectorPositions(true);
+
+ FieldType customType15 = new FieldType(TextField.TYPE_UNSTORED);
+ customType15.setTokenized(false);
+ customType15.setStoreTermVectors(true);
+ customType15.setStoreTermVectorOffsets(true);
+ customType15.setStoreTermVectorPositions(true);
+
switch (mode) {
- case 0: return new Field(fieldName, "some text", Store.YES, Index.ANALYZED, TermVector.NO);
- case 1: return new Field(fieldName, "some text", Store.NO, Index.ANALYZED, TermVector.NO);
- case 2: return new Field(fieldName, "some text", Store.YES, Index.NOT_ANALYZED, TermVector.NO);
- case 3: return new Field(fieldName, "some text", Store.NO, Index.NOT_ANALYZED, TermVector.NO);
- case 4: return new Field(fieldName, "some text", Store.YES, Index.ANALYZED, TermVector.WITH_OFFSETS);
- case 5: return new Field(fieldName, "some text", Store.NO, Index.ANALYZED, TermVector.WITH_OFFSETS);
- case 6: return new Field(fieldName, "some text", Store.YES, Index.NOT_ANALYZED, TermVector.WITH_OFFSETS);
- case 7: return new Field(fieldName, "some text", Store.NO, Index.NOT_ANALYZED, TermVector.WITH_OFFSETS);
- case 8: return new Field(fieldName, "some text", Store.YES, Index.ANALYZED, TermVector.WITH_POSITIONS);
- case 9: return new Field(fieldName, "some text", Store.NO, Index.ANALYZED, TermVector.WITH_POSITIONS);
- case 10: return new Field(fieldName, "some text", Store.YES, Index.NOT_ANALYZED, TermVector.WITH_POSITIONS);
- case 11: return new Field(fieldName, "some text", Store.NO, Index.NOT_ANALYZED, TermVector.WITH_POSITIONS);
- case 12: return new Field(fieldName, "some text", Store.YES, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS);
- case 13: return new Field(fieldName, "some text", Store.NO, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS);
- case 14: return new Field(fieldName, "some text", Store.YES, Index.NOT_ANALYZED, TermVector.WITH_POSITIONS_OFFSETS);
- case 15: return new Field(fieldName, "some text", Store.NO, Index.NOT_ANALYZED, TermVector.WITH_POSITIONS_OFFSETS);
+ case 0: return new Field(fieldName, customType, "some text");
+ case 1: return new TextField(fieldName, "some text");
+ case 2: return new Field(fieldName, customType2, "some text");
+ case 3: return new Field(fieldName, customType3, "some text");
+ case 4: return new Field(fieldName, customType4, "some text");
+ case 5: return new Field(fieldName, customType5, "some text");
+ case 6: return new Field(fieldName, customType6, "some text");
+ case 7: return new Field(fieldName, customType7, "some text");
+ case 8: return new Field(fieldName, customType8, "some text");
+ case 9: return new Field(fieldName, customType9, "some text");
+ case 10: return new Field(fieldName, customType10, "some text");
+ case 11: return new Field(fieldName, customType11, "some text");
+ case 12: return new Field(fieldName, customType12, "some text");
+ case 13: return new Field(fieldName, customType13, "some text");
+ case 14: return new Field(fieldName, customType14, "some text");
+ case 15: return new Field(fieldName, customType15, "some text");
default: return null;
}
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestCrash.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestCrash.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestCrash.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestCrash.java Mon Aug 15 22:03:41 2011
@@ -25,7 +25,8 @@ import org.apache.lucene.store.MockDirec
import org.apache.lucene.store.NoLockFactory;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
+import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.TextField;
public class TestCrash extends LuceneTestCase {
@@ -44,8 +45,10 @@ public class TestCrash extends LuceneTes
}
Document doc = new Document();
- doc.add(newField("content", "aaa", Field.Store.YES, Field.Index.ANALYZED));
- doc.add(newField("id", "0", Field.Store.YES, Field.Index.ANALYZED));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(false);
+ doc.add(newField("content", "aaa", customType));
+ doc.add(newField("id", "0", customType));
for(int i=0;i<157;i++)
writer.addDocument(doc);
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDeletionPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDeletionPolicy.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDeletionPolicy.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDeletionPolicy.java Mon Aug 15 22:03:41 2011
@@ -26,6 +26,7 @@ import java.util.Collection;
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.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.search.DefaultSimilarity;
import org.apache.lucene.search.IndexSearcher;
@@ -853,7 +854,7 @@ public class TestDeletionPolicy extends
private 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);
}
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDirectoryReader.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDirectoryReader.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDirectoryReader.java Mon Aug 15 22:03:41 2011
@@ -22,6 +22,8 @@ import org.apache.lucene.util.LuceneTest
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BytesRef;
@@ -202,7 +204,9 @@ public class TestDirectoryReader extends
new MockAnalyzer(random)).setOpenMode(
create ? OpenMode.CREATE : OpenMode.APPEND));
Document doc = new Document();
- doc.add(newField("body", s, Field.Store.YES, Field.Index.ANALYZED));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(false);
+ doc.add(newField("body", s, customType));
iw.addDocument(doc);
iw.close();
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDoc.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDoc.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDoc.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDoc.java Mon Aug 15 22:03:41 2011
@@ -32,6 +32,7 @@ import junit.textui.TestRunner;
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.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.store.Directory;
@@ -185,7 +186,7 @@ public class TestDoc extends LuceneTestC
{
File file = new File(workDir, fileName);
Document doc = new Document();
- doc.add(new Field("contents", new FileReader(file)));
+ doc.add(new TextField("contents", new FileReader(file)));
writer.addDocument(doc);
writer.commit();
return writer.newestSegment();
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDocTermOrds.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDocTermOrds.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDocTermOrds.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDocTermOrds.java Mon Aug 15 22:03:41 2011
@@ -28,6 +28,8 @@ import org.apache.lucene.analysis.MockAn
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.NumericField;
+import org.apache.lucene.document.StringField;
+import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DocTermOrds.TermOrdsIterator;
import org.apache.lucene.index.codecs.BlockTermsReader;
import org.apache.lucene.index.codecs.BlockTermsWriter;
@@ -66,7 +68,7 @@ public class TestDocTermOrds extends Luc
Directory dir = newDirectory();
final RandomIndexWriter w = new RandomIndexWriter(random, dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMergePolicy(newLogMergePolicy()));
Document doc = new Document();
- Field field = newField("field", "", Field.Index.ANALYZED);
+ Field field = newField("field", "", TextField.TYPE_UNSTORED);
doc.add(field);
field.setValue("a b c");
w.addDocument(doc);
@@ -281,7 +283,7 @@ public class TestDocTermOrds extends Luc
}
for(int ord : ordsForDocSet) {
ordsForDoc[upto++] = ord;
- Field field = newField("field", termsArray[ord].utf8ToString(), Field.Index.NOT_ANALYZED_NO_NORMS);
+ Field field = newField("field", termsArray[ord].utf8ToString(), StringField.TYPE_UNSTORED);
if (VERBOSE) {
System.out.println(" f=" + termsArray[ord].utf8ToString());
}
@@ -384,7 +386,7 @@ public class TestDocTermOrds extends Luc
}
for(int ord : ordsForDocSet) {
ordsForDoc[upto++] = ord;
- Field field = newField("field", termsArray[ord].utf8ToString(), Field.Index.NOT_ANALYZED_NO_NORMS);
+ Field field = newField("field", termsArray[ord].utf8ToString(), StringField.TYPE_UNSTORED);
if (VERBOSE) {
System.out.println(" f=" + termsArray[ord].utf8ToString());
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDocsAndPositions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDocsAndPositions.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDocsAndPositions.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDocsAndPositions.java Mon Aug 15 22:03:41 2011
@@ -22,7 +22,8 @@ import java.util.Arrays;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
+import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
import org.apache.lucene.index.IndexReader.ReaderContext;
import org.apache.lucene.store.Directory;
@@ -49,9 +50,11 @@ public class TestDocsAndPositions extend
newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)));
for (int i = 0; i < 39; i++) {
Document doc = new Document();
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setOmitNorms(true);
doc.add(newField(fieldName, "1 2 3 4 5 6 7 8 9 10 "
+ "1 2 3 4 5 6 7 8 9 10 " + "1 2 3 4 5 6 7 8 9 10 "
- + "1 2 3 4 5 6 7 8 9 10", Field.Store.NO, Field.Index.ANALYZED_NO_NORMS));
+ + "1 2 3 4 5 6 7 8 9 10", customType));
writer.addDocument(doc);
}
IndexReader reader = writer.getReader();
@@ -117,6 +120,8 @@ public class TestDocsAndPositions extend
int max = 1051;
int term = random.nextInt(max);
Integer[][] positionsInDoc = new Integer[numDocs][];
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setOmitNorms(true);
for (int i = 0; i < numDocs; i++) {
Document doc = new Document();
ArrayList<Integer> positions = new ArrayList<Integer>();
@@ -133,8 +138,7 @@ public class TestDocsAndPositions extend
builder.append(term);
positions.add(num);
}
- doc.add(newField(fieldName, builder.toString(), Field.Store.NO,
- Field.Index.ANALYZED_NO_NORMS));
+ doc.add(newField(fieldName, builder.toString(), customType));
positionsInDoc[i] = positions.toArray(new Integer[0]);
writer.addDocument(doc);
}
@@ -199,6 +203,8 @@ public class TestDocsAndPositions extend
int max = 15678;
int term = random.nextInt(max);
int[] freqInDoc = new int[numDocs];
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setOmitNorms(true);
for (int i = 0; i < numDocs; i++) {
Document doc = new Document();
StringBuilder builder = new StringBuilder();
@@ -209,8 +215,7 @@ public class TestDocsAndPositions extend
freqInDoc[i]++;
}
}
- doc.add(newField(fieldName, builder.toString(), Field.Store.NO,
- Field.Index.ANALYZED_NO_NORMS));
+ doc.add(newField(fieldName, builder.toString(), customType));
writer.addDocument(doc);
}
@@ -275,6 +280,8 @@ public class TestDocsAndPositions extend
RandomIndexWriter writer = new RandomIndexWriter(random, dir,
newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)));
int howMany = 1000;
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setOmitNorms(true);
for (int i = 0; i < 39; i++) {
Document doc = new Document();
StringBuilder builder = new StringBuilder();
@@ -285,8 +292,7 @@ public class TestDocsAndPositions extend
builder.append("odd ");
}
}
- doc.add(newField(fieldName, builder.toString(), Field.Store.NO,
- Field.Index.ANALYZED_NO_NORMS));
+ doc.add(newField(fieldName, builder.toString(), customType));
writer.addDocument(doc);
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDocumentWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDocumentWriter.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDocumentWriter.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestDocumentWriter.java Mon Aug 15 22:03:41 2011
@@ -30,11 +30,16 @@ import org.apache.lucene.analysis.tokena
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
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.Field.TermVector;
import org.apache.lucene.document.Fieldable;
import org.apache.lucene.index.FieldInfo.IndexOptions;
+=======
+import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.TextField;
+>>>>>>>
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IOContext.Context;
@@ -77,15 +82,15 @@ public class TestDocumentWriter extends
assertTrue(doc != null);
//System.out.println("Document: " + doc);
- Fieldable [] fields = doc.getFields("textField2");
+ IndexableField [] fields = doc.getFields("textField2");
assertTrue(fields != null && fields.length == 1);
assertTrue(fields[0].stringValue().equals(DocHelper.FIELD_2_TEXT));
- assertTrue(fields[0].isTermVectorStored());
+ assertTrue(fields[0].storeTermVectors());
fields = doc.getFields("textField1");
assertTrue(fields != null && fields.length == 1);
assertTrue(fields[0].stringValue().equals(DocHelper.FIELD_1_TEXT));
- assertFalse(fields[0].isTermVectorStored());
+ assertFalse(fields[0].storeTermVectors());
fields = doc.getFields("keyField");
assertTrue(fields != null && fields.length == 1);
@@ -125,8 +130,10 @@ public class TestDocumentWriter extends
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer));
Document doc = new Document();
- doc.add(newField("repeated", "repeated one", Field.Store.YES, Field.Index.ANALYZED));
- doc.add(newField("repeated", "repeated two", Field.Store.YES, Field.Index.ANALYZED));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ doc.add(newField("repeated", "repeated one", customType));
+ doc.add(newField("repeated", "repeated two", customType));
writer.addDocument(doc);
writer.commit();
@@ -190,7 +197,9 @@ public class TestDocumentWriter extends
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer));
Document doc = new Document();
- doc.add(newField("f1", "a 5 a a", Field.Store.YES, Field.Index.ANALYZED));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ doc.add(newField("f1", "a 5 a a", customType));
writer.addDocument(doc);
writer.commit();
@@ -216,8 +225,8 @@ public class TestDocumentWriter extends
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(random)));
Document doc = new Document();
-
- doc.add(new Field("preanalyzed", new TokenStream() {
+
+ doc.add(new TextField("preanalyzed", new TokenStream() {
private String[] tokens = new String[] {"term1", "term2", "term3", "term2"};
private int index = 0;
@@ -234,7 +243,7 @@ public class TestDocumentWriter extends
}
}
- }, TermVector.NO));
+ }));
writer.addDocument(doc);
writer.commit();
@@ -267,11 +276,20 @@ public class TestDocumentWriter extends
public void testMixedTermVectorSettingsSameField() throws Exception {
Document doc = new Document();
// f1 first without tv then with tv
- doc.add(newField("f1", "v1", Store.YES, Index.NOT_ANALYZED, TermVector.NO));
- doc.add(newField("f1", "v2", Store.YES, Index.NOT_ANALYZED, TermVector.WITH_POSITIONS_OFFSETS));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ customType.setTokenized(false);
+ doc.add(newField("f1", "v1", customType));
+ FieldType customType2 = new FieldType(TextField.TYPE_UNSTORED);
+ customType2.setStored(true);
+ customType2.setTokenized(false);
+ customType2.setStoreTermVectors(true);
+ customType2.setStoreTermVectorOffsets(true);
+ customType2.setStoreTermVectorPositions(true);
+ doc.add(newField("f1", "v2", customType2));
// f2 first with tv then without tv
- doc.add(newField("f2", "v1", Store.YES, Index.NOT_ANALYZED, TermVector.WITH_POSITIONS_OFFSETS));
- doc.add(newField("f2", "v2", Store.YES, Index.NOT_ANALYZED, TermVector.NO));
+ doc.add(newField("f2", "v1", customType2));
+ doc.add(newField("f2", "v2", customType));
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(random)));
@@ -300,13 +318,24 @@ public class TestDocumentWriter extends
public void testLUCENE_1590() throws Exception {
Document doc = new Document();
// f1 has no norms
- doc.add(newField("f1", "v1", Store.NO, Index.ANALYZED_NO_NORMS));
- doc.add(newField("f1", "v2", Store.YES, Index.NO));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setOmitNorms(true);
+ FieldType customType2 = new FieldType();
+ customType2.setStored(true);
+ doc.add(newField("f1", "v1", customType));
+ doc.add(newField("f1", "v2", customType2));
// f2 has no TF
+<<<<<<<
Field f = newField("f2", "v1", Store.NO, Index.ANALYZED);
f.setIndexOptions(IndexOptions.DOCS_ONLY);
+=======
+ FieldType customType3 = new FieldType(TextField.TYPE_UNSTORED);
+ customType3.setStored(true);
+ customType3.setOmitTermFreqAndPositions(true);
+ Field f = newField("f2", "v1", customType3);
+>>>>>>>
doc.add(f);
- doc.add(newField("f2", "v2", Store.YES, Index.NO));
+ doc.add(newField("f2", "v2", customType2));
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(random)));