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 [9/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/index/TestMaxTermFrequency.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestMaxTermFrequency.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestMaxTermFrequency.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestMaxTermFrequency.java Mon Aug 15 22:03:41 2011
@@ -26,6 +26,7 @@ import org.apache.lucene.analysis.MockAn
import org.apache.lucene.analysis.MockTokenizer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.document.TextField;
import org.apache.lucene.search.DefaultSimilarity;
import org.apache.lucene.search.DefaultSimilarityProvider;
import org.apache.lucene.search.Similarity;
@@ -56,7 +57,7 @@ public class TestMaxTermFrequency extend
});
RandomIndexWriter writer = new RandomIndexWriter(random, dir, config);
Document doc = new Document();
- Field foo = newField("foo", "", Field.Store.NO, Field.Index.ANALYZED);
+ Field foo = newField("foo", "", TextField.TYPE_UNSTORED);
doc.add(foo);
for (int i = 0; i < 100; i++) {
foo.setValue(addValue());
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestMultiFields.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestMultiFields.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestMultiFields.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestMultiFields.java Mon Aug 15 22:03:41 2011
@@ -40,9 +40,9 @@ public class TestMultiFields extends Luc
int numDocs = _TestUtil.nextInt(random, 1, 100 * RANDOM_MULTIPLIER);
Document doc = new Document();
- Field f = newField("field", "", Field.Store.NO, Field.Index.NOT_ANALYZED);
+ Field f = newField("field", "", StringField.TYPE_UNSTORED);
doc.add(f);
- Field id = newField("id", "", Field.Store.NO, Field.Index.NOT_ANALYZED);
+ Field id = newField("id", "", StringField.TYPE_UNSTORED);
doc.add(id);
boolean onlyUniqueTerms = random.nextBoolean();
@@ -136,7 +136,7 @@ public class TestMultiFields extends Luc
Directory dir = newDirectory();
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)));
Document d = new Document();
- d.add(newField("f", "j", Field.Store.NO, Field.Index.NOT_ANALYZED));
+ d.add(newField("f", "j", StringField.TYPE_UNSTORED));
w.addDocument(d);
w.commit();
w.addDocument(d);
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestMultiLevelSkipList.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestMultiLevelSkipList.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestMultiLevelSkipList.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestMultiLevelSkipList.java Mon Aug 15 22:03:41 2011
@@ -27,8 +27,7 @@ import org.apache.lucene.analysis.TokenF
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
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.TextField;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
@@ -76,7 +75,7 @@ public class TestMultiLevelSkipList exte
Term term = new Term("test", "a");
for (int i = 0; i < 5000; i++) {
Document d1 = new Document();
- d1.add(newField(term.field(), term.text(), Store.NO, Index.ANALYZED));
+ d1.add(newField(term.field(), term.text(), TextField.TYPE_UNSTORED));
writer.addDocument(d1);
}
writer.commit();
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestNRTThreads.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestNRTThreads.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestNRTThreads.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestNRTThreads.java Mon Aug 15 22:03:41 2011
@@ -33,6 +33,12 @@ import java.util.concurrent.atomic.Atomi
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.StringField;
+import org.apache.lucene.document.TextField;
+>>>>>>>
import org.apache.lucene.index.codecs.CodecProvider;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.PhraseQuery;
@@ -69,6 +75,27 @@ public class TestNRTThreads extends Luce
}
@Test
+<<<<<<<
+=======
+ // TODO: is there a pre-existing way to do this!!!
+ private Document cloneDoc(Document doc1) {
+ final Document doc2 = new Document();
+ for(IndexableField field1 : doc1.getFields()) {
+
+ FieldType ft = new FieldType();
+ ft.setStored(field1.stored());
+ ft.setIndexed(field1.indexed());
+ ft.setTokenized(field1.tokenized());
+ ft.setOmitNorms(field1.omitNorms());
+ ft.setOmitTermFreqAndPositions(field1.omitTermFreqAndPositions());
+
+ Field field2 = new Field(field1.name(),
+ ft,
+ field1.stringValue());
+ doc2.add(field2);
+ }
+
+>>>>>>>
public void testNRTThreads() throws Exception {
final long t0 = System.currentTimeMillis();
@@ -163,7 +190,7 @@ public class TestNRTThreads extends Luce
final String addedField;
if (random.nextBoolean()) {
addedField = "extra" + random.nextInt(10);
- doc.add(new Field(addedField, "a random field", Field.Store.NO, Field.Index.ANALYZED));
+ doc.add(new TextField(addedField, "a random field"));
} else {
addedField = null;
}
@@ -188,7 +215,7 @@ public class TestNRTThreads extends Luce
packID = packCount.getAndIncrement() + "";
}
- final Field packIDField = newField("packID", packID, Field.Store.YES, Field.Index.NOT_ANALYZED);
+ final Field packIDField = newField("packID", packID, StringField.TYPE_STORED);
final List<String> docIDs = new ArrayList<String>();
final SubDocs subDocs = new SubDocs(packID, docIDs);
final List<Document> docsList = new ArrayList<Document>();
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestNoDeletionPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestNoDeletionPolicy.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestNoDeletionPolicy.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestNoDeletionPolicy.java Mon Aug 15 22:03:41 2011
@@ -23,8 +23,8 @@ import java.lang.reflect.Modifier;
import java.util.Arrays;
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.FieldType;
+import org.apache.lucene.document.TextField;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
import org.junit.Test;
@@ -72,9 +72,11 @@ public class TestNoDeletionPolicy extend
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(random))
.setIndexDeletionPolicy(NoDeletionPolicy.INSTANCE));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
for (int i = 0; i < 10; i++) {
Document doc = new Document();
- doc.add(newField("c", "a" + i, Store.YES, Index.ANALYZED));
+ doc.add(newField("c", "a" + i, customType));
writer.addDocument(doc);
writer.commit();
assertEquals("wrong number of commits !", i + 1, IndexReader.listCommits(dir).size());
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestNorms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestNorms.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestNorms.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestNorms.java Mon Aug 15 22:03:41 2011
@@ -25,8 +25,7 @@ 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.TextField;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.search.DefaultSimilarity;
import org.apache.lucene.search.DefaultSimilarityProvider;
@@ -220,7 +219,7 @@ public class TestNorms extends LuceneTes
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
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,TextField.TYPE_UNSTORED);
f.setBoost(boost);
d.add(f);
}
@@ -277,8 +276,8 @@ public class TestNorms extends LuceneTes
});
RandomIndexWriter writer = new RandomIndexWriter(random, dir, config);
Document doc = new Document();
- Field foo = newField("foo", "", Field.Store.NO, Field.Index.ANALYZED);
- Field bar = newField("bar", "", Field.Store.NO, Field.Index.ANALYZED);
+ Field foo = newField("foo", "", TextField.TYPE_UNSTORED);
+ Field bar = newField("bar", "", TextField.TYPE_UNSTORED);
doc.add(foo);
doc.add(bar);
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestOmitNorms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestOmitNorms.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestOmitNorms.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestOmitNorms.java Mon Aug 15 22:03:41 2011
@@ -25,6 +25,8 @@ 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.FieldType;
+import org.apache.lucene.document.TextField;
import org.apache.lucene.store.Directory;
public class TestOmitNorms extends LuceneTestCase {
@@ -37,12 +39,13 @@ public class TestOmitNorms extends Lucen
Document d = new Document();
// this field will have norms
- Field f1 = newField("f1", "This field has norms", Field.Store.NO, Field.Index.ANALYZED);
+ Field f1 = newField("f1", "This field has norms", TextField.TYPE_UNSTORED);
d.add(f1);
// this field will NOT have norms
- Field f2 = newField("f2", "This field has NO norms in all docs", Field.Store.NO, Field.Index.ANALYZED);
- f2.setOmitNorms(true);
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setOmitNorms(true);
+ Field f2 = newField("f2", "This field has NO norms in all docs", customType);
d.add(f2);
writer.addDocument(d);
@@ -52,11 +55,9 @@ public class TestOmitNorms extends Lucen
d = new Document();
// Reverse
- f1.setOmitNorms(true);
- d.add(f1);
+ d.add(newField("f1", "This field has norms", customType));
- f2.setOmitNorms(false);
- d.add(f2);
+ d.add(newField("f2", "This field has NO norms in all docs", TextField.TYPE_UNSTORED));
writer.addDocument(d);
@@ -88,12 +89,13 @@ public class TestOmitNorms extends Lucen
Document d = new Document();
// this field will have norms
- Field f1 = newField("f1", "This field has norms", Field.Store.NO, Field.Index.ANALYZED);
+ Field f1 = newField("f1", "This field has norms", TextField.TYPE_UNSTORED);
d.add(f1);
// this field will NOT have norms
- Field f2 = newField("f2", "This field has NO norms in all docs", Field.Store.NO, Field.Index.ANALYZED);
- f2.setOmitNorms(true);
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setOmitNorms(true);
+ Field f2 = newField("f2", "This field has NO norms in all docs", customType);
d.add(f2);
for (int i = 0; i < 30; i++) {
@@ -105,11 +107,9 @@ public class TestOmitNorms extends Lucen
d = new Document();
// Reverese
- f1.setOmitNorms(true);
- d.add(f1);
+ d.add(newField("f1", "This field has norms", customType));
- f2.setOmitNorms(false);
- d.add(f2);
+ d.add(newField("f2", "This field has NO norms in all docs", TextField.TYPE_UNSTORED));
for (int i = 0; i < 30; i++) {
writer.addDocument(d);
@@ -144,18 +144,19 @@ public class TestOmitNorms extends Lucen
Document d = new Document();
// this field will have norms
- Field f1 = newField("f1", "This field has norms", Field.Store.NO, Field.Index.ANALYZED);
+ Field f1 = newField("f1", "This field has norms", TextField.TYPE_UNSTORED);
d.add(f1);
// this field will NOT have norms
- Field f2 = newField("f2", "This field has NO norms in all docs", Field.Store.NO, Field.Index.ANALYZED);
+
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setOmitNorms(true);
+ Field f2 = newField("f2", "This field has NO norms in all docs", customType);
d.add(f2);
for (int i = 0; i < 5; i++) {
writer.addDocument(d);
}
-
- f2.setOmitNorms(true);
for (int i = 0; i < 20; i++) {
writer.addDocument(d);
@@ -194,9 +195,10 @@ public class TestOmitNorms extends Lucen
lmp.setMergeFactor(2);
lmp.setUseCompoundFile(false);
Document d = new Document();
-
- Field f1 = newField("f1", "This field has no norms", Field.Store.NO, Field.Index.ANALYZED);
- f1.setOmitNorms(true);
+
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setOmitNorms(true);
+ Field f1 = newField("f1", "This field has no norms", customType);
d.add(f1);
for (int i = 0; i < 30; i++) {
@@ -224,16 +226,25 @@ public class TestOmitNorms extends Lucen
*/
public void testOmitNormsCombos() throws IOException {
// indexed with norms
- Field norms = new Field("foo", "a", Field.Store.YES, Field.Index.ANALYZED);
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ Field norms = new Field("foo", customType, "a");
// indexed without norms
- Field noNorms = new Field("foo", "a", Field.Store.YES, Field.Index.ANALYZED_NO_NORMS);
+ FieldType customType1 = new FieldType(TextField.TYPE_UNSTORED);
+ customType1.setStored(true);
+ customType1.setOmitNorms(true);
+ Field noNorms = new Field("foo", customType1, "a");
// not indexed, but stored
- Field noIndex = new Field("foo", "a", Field.Store.YES, Field.Index.NO);
+ FieldType customType2 = new FieldType();
+ customType2.setStored(true);
+ Field noIndex = new Field("foo", customType2, "a");
// not indexed but stored, omitNorms is set
- Field noNormsNoIndex = new Field("foo", "a", Field.Store.YES, Field.Index.NO);
- noNormsNoIndex.setOmitNorms(true);
+ FieldType customType3 = new FieldType();
+ customType3.setStored(true);
+ customType3.setOmitNorms(true);
+ Field noNormsNoIndex = new Field("foo", customType3, "a");
// not indexed nor stored (doesnt exist at all, we index a different field instead)
- Field emptyNorms = new Field("bar", "a", Field.Store.YES, Field.Index.ANALYZED);
+ Field emptyNorms = new Field("bar", customType, "a");
assertNotNull(getNorms("foo", norms, norms));
assertNull(getNorms("foo", norms, noNorms));
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestOmitTf.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestOmitTf.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestOmitTf.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestOmitTf.java Mon Aug 15 22:03:41 2011
@@ -27,7 +27,12 @@ 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.index.FieldInfo.IndexOptions;
+=======
+import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.TextField;
+>>>>>>>
import org.apache.lucene.index.IndexReader.AtomicReaderContext;
import org.apache.lucene.search.*;
import org.apache.lucene.search.BooleanClause.Occur;
@@ -54,6 +59,13 @@ public class TestOmitTf extends LuceneTe
}
}
+ private static final FieldType omitType = new FieldType(TextField.TYPE_UNSTORED);
+ private static final FieldType normalType = new FieldType(TextField.TYPE_UNSTORED);
+
+ static {
+ omitType.setOmitTermFreqAndPositions(true);
+ }
+
// Tests whether the DocumentWriter correctly enable the
// omitTermFreqAndPositions bit in the FieldInfo
public void testOmitTermFreqAndPositions() throws Exception {
@@ -63,12 +75,16 @@ public class TestOmitTf extends LuceneTe
Document d = new Document();
// this field will have Tf
- Field f1 = newField("f1", "This field has term freqs", Field.Store.NO, Field.Index.ANALYZED);
+ Field f1 = newField("f1", "This field has term freqs", normalType);
d.add(f1);
// this field will NOT have Tf
+<<<<<<<
Field f2 = newField("f2", "This field has NO Tf in all docs", Field.Store.NO, Field.Index.ANALYZED);
f2.setIndexOptions(IndexOptions.DOCS_ONLY);
+=======
+ Field f2 = newField("f2", "This field has NO Tf in all docs", omitType);
+>>>>>>>
d.add(f2);
writer.addDocument(d);
@@ -78,10 +94,18 @@ public class TestOmitTf extends LuceneTe
d = new Document();
// Reverse
+<<<<<<<
f1.setIndexOptions(IndexOptions.DOCS_ONLY);
+=======
+ f1 = newField("f1", "This field has term freqs", omitType);
+>>>>>>>
d.add(f1);
+<<<<<<<
f2.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
+=======
+ f2 = newField("f2", "This field has NO Tf in all docs", normalType);
+>>>>>>>
d.add(f2);
writer.addDocument(d);
@@ -115,12 +139,16 @@ public class TestOmitTf extends LuceneTe
Document d = new Document();
// this field will have Tf
- Field f1 = newField("f1", "This field has term freqs", Field.Store.NO, Field.Index.ANALYZED);
+ Field f1 = newField("f1", "This field has term freqs", normalType);
d.add(f1);
// this field will NOT have Tf
+<<<<<<<
Field f2 = newField("f2", "This field has NO Tf in all docs", Field.Store.NO, Field.Index.ANALYZED);
f2.setIndexOptions(IndexOptions.DOCS_ONLY);
+=======
+ Field f2 = newField("f2", "This field has NO Tf in all docs", omitType);
+>>>>>>>
d.add(f2);
for(int i=0;i<30;i++)
@@ -131,10 +159,18 @@ public class TestOmitTf extends LuceneTe
d = new Document();
// Reverese
+<<<<<<<
f1.setIndexOptions(IndexOptions.DOCS_ONLY);
+=======
+ f1 = newField("f1", "This field has term freqs", omitType);
+>>>>>>>
d.add(f1);
+<<<<<<<
f2.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS);
+=======
+ f2 = newField("f2", "This field has NO Tf in all docs", normalType);
+>>>>>>>
d.add(f2);
for(int i=0;i<30;i++)
@@ -169,18 +205,21 @@ public class TestOmitTf extends LuceneTe
Document d = new Document();
// this field will have Tf
- Field f1 = newField("f1", "This field has term freqs", Field.Store.NO, Field.Index.ANALYZED);
+ Field f1 = newField("f1", "This field has term freqs", normalType);
d.add(f1);
// this field will NOT have Tf
- Field f2 = newField("f2", "This field has NO Tf in all docs", Field.Store.NO, Field.Index.ANALYZED);
+ Field f2 = newField("f2", "This field has NO Tf in all docs", omitType);
d.add(f2);
for(int i=0;i<5;i++)
writer.addDocument(d);
+<<<<<<<
f2.setIndexOptions(IndexOptions.DOCS_ONLY);
+=======
+>>>>>>>
for(int i=0;i<20;i++)
writer.addDocument(d);
@@ -218,8 +257,12 @@ public class TestOmitTf extends LuceneTe
lmp.setUseCompoundFile(false);
Document d = new Document();
+<<<<<<<
Field f1 = newField("f1", "This field has no term freqs", Field.Store.NO, Field.Index.ANALYZED);
f1.setIndexOptions(IndexOptions.DOCS_ONLY);
+=======
+ Field f1 = newField("f1", "This field has term freqs", omitType);
+>>>>>>>
d.add(f1);
for(int i=0;i<30;i++)
@@ -265,11 +308,15 @@ public class TestOmitTf extends LuceneTe
Document d = new Document();
sb.append(term).append(" ");
String content = sb.toString();
+<<<<<<<
Field noTf = newField("noTf", content + (i%2==0 ? "" : " notf"), Field.Store.NO, Field.Index.ANALYZED);
noTf.setIndexOptions(IndexOptions.DOCS_ONLY);
+=======
+ Field noTf = newField("noTf", content + (i%2==0 ? "" : " notf"), omitType);
+>>>>>>>
d.add(noTf);
- Field tf = newField("tf", content + (i%2==0 ? " tf" : ""), Field.Store.NO, Field.Index.ANALYZED);
+ Field tf = newField("tf", content + (i%2==0 ? " tf" : ""), normalType);
d.add(tf);
writer.addDocument(d);
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestParallelReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestParallelReader.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestParallelReader.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestParallelReader.java Mon Aug 15 22:03:41 2011
@@ -18,14 +18,13 @@ package org.apache.lucene.index;
*/
import java.io.IOException;
-import java.util.Arrays;
import java.util.Collection;
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.MapFieldSelector;
+import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.TextField;
import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.*;
import org.apache.lucene.store.Directory;
@@ -89,30 +88,6 @@ public class TestParallelReader extends
dir2.close();
}
- public void testDocument() throws IOException {
- Directory dir1 = getDir1(random);
- Directory dir2 = getDir2(random);
- ParallelReader pr = new ParallelReader();
- pr.add(IndexReader.open(dir1, false));
- pr.add(IndexReader.open(dir2, false));
-
- Document doc11 = pr.document(0, new MapFieldSelector("f1"));
- Document doc24 = pr.document(1, new MapFieldSelector(Arrays.asList("f4")));
- Document doc223 = pr.document(1, new MapFieldSelector("f2", "f3"));
-
- assertEquals(1, doc11.getFields().size());
- assertEquals(1, doc24.getFields().size());
- assertEquals(2, doc223.getFields().size());
-
- assertEquals("v1", doc11.get("f1"));
- assertEquals("v2", doc24.get("f4"));
- assertEquals("v2", doc223.get("f2"));
- assertEquals("v2", doc223.get("f3"));
- pr.close();
- dir1.close();
- dir2.close();
- }
-
public void testIncompatibleIndexes() throws IOException {
// two documents:
Directory dir1 = getDir1(random);
@@ -121,7 +96,10 @@ public class TestParallelReader extends
Directory dir2 = newDirectory();
IndexWriter w2 = new IndexWriter(dir2, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)));
Document d3 = new Document();
- d3.add(newField("f3", "v1", Field.Store.YES, Field.Index.ANALYZED));
+
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ d3.add(newField("f3", "v1", customType));
w2.addDocument(d3);
w2.close();
@@ -179,7 +157,9 @@ public class TestParallelReader extends
setMergePolicy(newLogMergePolicy(10))
);
Document d = new Document();
- d.add(newField("f1", "v1", Field.Store.YES, Field.Index.ANALYZED));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ d.add(newField("f1", "v1", customType));
modifier.addDocument(d);
modifier.close();
@@ -189,7 +169,7 @@ public class TestParallelReader extends
setMergePolicy(newLogMergePolicy(10))
);
d = new Document();
- d.add(newField("f2", "v2", Field.Store.YES, Field.Index.ANALYZED));
+ d.add(newField("f2", "v2", customType));
modifier.addDocument(d);
modifier.close();
@@ -246,16 +226,18 @@ public class TestParallelReader extends
dir = newDirectory();
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)));
Document d1 = new Document();
- d1.add(newField("f1", "v1", Field.Store.YES, Field.Index.ANALYZED));
- d1.add(newField("f2", "v1", Field.Store.YES, Field.Index.ANALYZED));
- d1.add(newField("f3", "v1", Field.Store.YES, Field.Index.ANALYZED));
- d1.add(newField("f4", "v1", Field.Store.YES, Field.Index.ANALYZED));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ d1.add(newField("f1", "v1", customType));
+ d1.add(newField("f2", "v1", customType));
+ d1.add(newField("f3", "v1", customType));
+ d1.add(newField("f4", "v1", customType));
w.addDocument(d1);
Document d2 = new Document();
- d2.add(newField("f1", "v2", Field.Store.YES, Field.Index.ANALYZED));
- d2.add(newField("f2", "v2", Field.Store.YES, Field.Index.ANALYZED));
- d2.add(newField("f3", "v2", Field.Store.YES, Field.Index.ANALYZED));
- d2.add(newField("f4", "v2", Field.Store.YES, Field.Index.ANALYZED));
+ d2.add(newField("f1", "v2", customType));
+ d2.add(newField("f2", "v2", customType));
+ d2.add(newField("f3", "v2", customType));
+ d2.add(newField("f4", "v2", customType));
w.addDocument(d2);
w.close();
@@ -276,12 +258,14 @@ public class TestParallelReader extends
Directory dir1 = newDirectory();
IndexWriter w1 = new IndexWriter(dir1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)));
Document d1 = new Document();
- d1.add(newField("f1", "v1", Field.Store.YES, Field.Index.ANALYZED));
- d1.add(newField("f2", "v1", Field.Store.YES, Field.Index.ANALYZED));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ d1.add(newField("f1", "v1", customType));
+ d1.add(newField("f2", "v1", customType));
w1.addDocument(d1);
Document d2 = new Document();
- d2.add(newField("f1", "v2", Field.Store.YES, Field.Index.ANALYZED));
- d2.add(newField("f2", "v2", Field.Store.YES, Field.Index.ANALYZED));
+ d2.add(newField("f1", "v2", customType));
+ d2.add(newField("f2", "v2", customType));
w1.addDocument(d2);
w1.close();
return dir1;
@@ -289,14 +273,16 @@ public class TestParallelReader extends
private Directory getDir2(Random random) throws IOException {
Directory dir2 = newDirectory();
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
IndexWriter w2 = new IndexWriter(dir2, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)));
Document d3 = new Document();
- d3.add(newField("f3", "v1", Field.Store.YES, Field.Index.ANALYZED));
- d3.add(newField("f4", "v1", Field.Store.YES, Field.Index.ANALYZED));
+ d3.add(newField("f3", "v1", customType));
+ d3.add(newField("f4", "v1", customType));
w2.addDocument(d3);
Document d4 = new Document();
- d4.add(newField("f3", "v2", Field.Store.YES, Field.Index.ANALYZED));
- d4.add(newField("f4", "v2", Field.Store.YES, Field.Index.ANALYZED));
+ d4.add(newField("f3", "v2", customType));
+ d4.add(newField("f4", "v2", customType));
w2.addDocument(d4);
w2.close();
return dir2;
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestParallelReaderEmptyIndex.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestParallelReaderEmptyIndex.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestParallelReaderEmptyIndex.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestParallelReaderEmptyIndex.java Mon Aug 15 22:03:41 2011
@@ -25,9 +25,8 @@ import org.apache.lucene.util._TestUtil;
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.TermVector;
+import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
/**
@@ -77,11 +76,11 @@ public class TestParallelReaderEmptyInde
{
IndexWriter iw = new IndexWriter(rd1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)));
Document doc = new Document();
- doc.add(newField("test", "", Store.NO, Index.ANALYZED,
- TermVector.YES));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStoreTermVectors(true);
+ doc.add(newField("test", "", customType));
iw.addDocument(doc);
- doc.add(newField("test", "", Store.NO, Index.ANALYZED,
- TermVector.NO));
+ doc.add(newField("test", "", TextField.TYPE_UNSTORED));
iw.addDocument(doc);
iw.close();
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestParallelTermEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestParallelTermEnum.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestParallelTermEnum.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestParallelTermEnum.java Mon Aug 15 22:03:41 2011
@@ -22,8 +22,8 @@ import java.io.IOException;
import org.apache.lucene.util.LuceneTestCase;
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.FieldType;
+import org.apache.lucene.document.TextField;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.Bits;
@@ -41,11 +41,11 @@ public class TestParallelTermEnum extend
IndexWriter iw1 = new IndexWriter(rd1, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)));
doc = new Document();
- doc.add(newField("field1", "the quick brown fox jumps", Store.YES,
- Index.ANALYZED));
- doc.add(newField("field2", "the quick brown fox jumps", Store.YES,
- Index.ANALYZED));
- doc.add(newField("field4", "", Store.NO, Index.ANALYZED));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ doc.add(newField("field1", "the quick brown fox jumps", customType));
+ doc.add(newField("field2", "the quick brown fox jumps", customType));
+ doc.add(newField("field4", "", TextField.TYPE_UNSTORED));
iw1.addDocument(doc);
iw1.close();
@@ -53,11 +53,9 @@ public class TestParallelTermEnum extend
IndexWriter iw2 = new IndexWriter(rd2, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer(random)));
doc = new Document();
- doc.add(newField("field0", "", Store.NO, Index.ANALYZED));
- doc.add(newField("field1", "the fox jumps over the lazy dog",
- Store.YES, Index.ANALYZED));
- doc.add(newField("field3", "the fox jumps over the lazy dog",
- Store.YES, Index.ANALYZED));
+ doc.add(newField("field0", "", TextField.TYPE_UNSTORED));
+ doc.add(newField("field1", "the fox jumps over the lazy dog", customType));
+ doc.add(newField("field3", "the fox jumps over the lazy dog", customType));
iw2.addDocument(doc);
iw2.close();
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestPayloadProcessorProvider.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestPayloadProcessorProvider.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestPayloadProcessorProvider.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestPayloadProcessorProvider.java Mon Aug 15 22:03:41 2011
@@ -28,9 +28,8 @@ import org.apache.lucene.analysis.TokenS
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
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.PayloadProcessorProvider.DirPayloadProcessor;
import org.apache.lucene.index.PayloadProcessorProvider.PayloadProcessor;
import org.apache.lucene.search.DocIdSetIterator;
@@ -135,12 +134,14 @@ public class TestPayloadProcessorProvide
);
TokenStream payloadTS1 = new PayloadTokenStream("p1");
TokenStream payloadTS2 = new PayloadTokenStream("p2");
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setOmitNorms(true);
for (int i = 0; i < NUM_DOCS; i++) {
Document doc = new Document();
- doc.add(newField("id", "doc" + i, Store.NO, Index.NOT_ANALYZED_NO_NORMS));
- doc.add(newField("content", "doc content " + i, Store.NO, Index.ANALYZED));
- doc.add(new Field("p", payloadTS1));
- doc.add(new Field("p", payloadTS2));
+ doc.add(newField("id", "doc" + i, customType));
+ doc.add(newField("content", "doc content " + i, TextField.TYPE_UNSTORED));
+ doc.add(new TextField("p", payloadTS1));
+ doc.add(new TextField("p", payloadTS2));
writer.addDocument(doc);
if (multipleCommits && (i % 4 == 0)) {
writer.commit();
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestPayloads.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestPayloads.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestPayloads.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestPayloads.java Mon Aug 15 22:03:41 2011
@@ -35,6 +35,8 @@ import org.apache.lucene.analysis.tokena
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
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.search.DocIdSetIterator;
import org.apache.lucene.store.Directory;
@@ -101,15 +103,15 @@ public class TestPayloads extends Lucene
IndexWriter writer = new IndexWriter(ram, newIndexWriterConfig( TEST_VERSION_CURRENT, analyzer));
Document d = new Document();
// this field won't have any payloads
- d.add(newField("f1", "This field has no payloads", Field.Store.NO, Field.Index.ANALYZED));
+ d.add(newField("f1", "This field has no payloads", TextField.TYPE_UNSTORED));
// this field will have payloads in all docs, however not for all term positions,
// so this field is used to check if the DocumentWriter correctly enables the payloads bit
// even if only some term positions have payloads
- d.add(newField("f2", "This field has payloads in all docs", Field.Store.NO, Field.Index.ANALYZED));
- d.add(newField("f2", "This field has payloads in all docs", Field.Store.NO, Field.Index.ANALYZED));
+ d.add(newField("f2", "This field has payloads in all docs", TextField.TYPE_UNSTORED));
+ d.add(newField("f2", "This field has payloads in all docs", TextField.TYPE_UNSTORED));
// this field is used to verify if the SegmentMerger enables payloads for a field if it has payloads
// enabled in only some documents
- d.add(newField("f3", "This field has payloads in some docs", Field.Store.NO, Field.Index.ANALYZED));
+ d.add(newField("f3", "This field has payloads in some docs", TextField.TYPE_UNSTORED));
// only add payload data for field f2
analyzer.setPayloadData("f2", 1, "somedata".getBytes(), 0, 1);
writer.addDocument(d);
@@ -128,10 +130,10 @@ public class TestPayloads extends Lucene
writer = new IndexWriter(ram, newIndexWriterConfig( TEST_VERSION_CURRENT,
analyzer).setOpenMode(OpenMode.CREATE));
d = new Document();
- d.add(newField("f1", "This field has no payloads", Field.Store.NO, Field.Index.ANALYZED));
- d.add(newField("f2", "This field has payloads in all docs", Field.Store.NO, Field.Index.ANALYZED));
- d.add(newField("f2", "This field has payloads in all docs", Field.Store.NO, Field.Index.ANALYZED));
- d.add(newField("f3", "This field has payloads in some docs", Field.Store.NO, Field.Index.ANALYZED));
+ d.add(newField("f1", "This field has no payloads", TextField.TYPE_UNSTORED));
+ d.add(newField("f2", "This field has payloads in all docs", TextField.TYPE_UNSTORED));
+ d.add(newField("f2", "This field has payloads in all docs", TextField.TYPE_UNSTORED));
+ d.add(newField("f3", "This field has payloads in some docs", TextField.TYPE_UNSTORED));
// add payload data for field f2 and f3
analyzer.setPayloadData("f2", "somedata".getBytes(), 0, 1);
analyzer.setPayloadData("f3", "somedata".getBytes(), 0, 3);
@@ -188,7 +190,7 @@ public class TestPayloads extends Lucene
byte[] payloadData = generateRandomData(payloadDataLength);
Document d = new Document();
- d.add(newField(fieldName, content, Field.Store.NO, Field.Index.ANALYZED));
+ d.add(newField(fieldName, content, TextField.TYPE_UNSTORED));
// add the same document multiple times to have the same payload lengths for all
// occurrences within two consecutive skip intervals
int offset = 0;
@@ -319,7 +321,7 @@ public class TestPayloads extends Lucene
String singleTerm = "lucene";
d = new Document();
- d.add(newField(fieldName, singleTerm, Field.Store.NO, Field.Index.ANALYZED));
+ d.add(newField(fieldName, singleTerm, TextField.TYPE_UNSTORED));
// add a payload whose length is greater than the buffer size of BufferedIndexOutput
payloadData = generateRandomData(2000);
analyzer.setPayloadData(fieldName, payloadData, 100, 1500);
@@ -504,7 +506,7 @@ public class TestPayloads extends Lucene
try {
for (int j = 0; j < numDocs; j++) {
Document d = new Document();
- d.add(new Field(field, new PoolingPayloadTokenStream(pool)));
+ d.add(new TextField(field, new PoolingPayloadTokenStream(pool)));
writer.addDocument(d);
}
} catch (Exception e) {
@@ -605,14 +607,16 @@ public class TestPayloads extends Lucene
RandomIndexWriter writer = new RandomIndexWriter(random, dir,
new MockAnalyzer(random, MockTokenizer.WHITESPACE, true));
Document doc = new Document();
- doc.add(new Field("hasMaybepayload", "here we go", Field.Store.YES, Field.Index.ANALYZED));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ doc.add(new Field("hasMaybepayload", customType, "here we go"));
writer.addDocument(doc);
writer.close();
writer = new RandomIndexWriter(random, dir,
new MockAnalyzer(random, MockTokenizer.WHITESPACE, true));
doc = new Document();
- doc.add(new Field("hasMaybepayload2", "here we go", Field.Store.YES, Field.Index.ANALYZED));
+ doc.add(new Field("hasMaybepayload2", customType, "here we go"));
writer.addDocument(doc);
writer.addDocument(doc);
writer.optimize();
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestPerFieldCodecSupport.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestPerFieldCodecSupport.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestPerFieldCodecSupport.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestPerFieldCodecSupport.java Mon Aug 15 22:03:41 2011
@@ -22,7 +22,8 @@ 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.FieldType;
+import org.apache.lucene.document.TextField;
import org.apache.lucene.index.CheckIndex.Status;
import org.apache.lucene.index.CheckIndex.Status.SegmentInfoStatus;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
@@ -63,7 +64,7 @@ public class TestPerFieldCodecSupport ex
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);
}
}
@@ -71,16 +72,18 @@ public class TestPerFieldCodecSupport ex
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);
}
}
private void addDocs3(IndexWriter writer, int numDocs) throws IOException {
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
for (int i = 0; i < numDocs; i++) {
Document doc = new Document();
- doc.add(newField("content", "ccc", Field.Store.NO, Field.Index.ANALYZED));
- doc.add(newField("id", "" + i, Field.Store.YES, Field.Index.ANALYZED));
+ doc.add(newField("content", "ccc", TextField.TYPE_UNSTORED));
+ doc.add(newField("id", "" + i, customType));
writer.addDocument(doc);
}
}
@@ -271,8 +274,6 @@ public class TestPerFieldCodecSupport ex
@Test
public void testStressPerFieldCodec() throws IOException {
Directory dir = newDirectory(random);
- Index[] indexValue = new Index[] { Index.ANALYZED, Index.ANALYZED_NO_NORMS,
- Index.NOT_ANALYZED, Index.NOT_ANALYZED_NO_NORMS };
final int docsPerRound = 97;
int numRounds = atLeast(1);
for (int i = 0; i < numRounds; i++) {
@@ -297,9 +298,11 @@ public class TestPerFieldCodecSupport ex
for (int j = 0; j < docsPerRound; j++) {
final Document doc = new Document();
for (int k = 0; k < num; k++) {
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setTokenized(random.nextBoolean());
+ customType.setOmitNorms(random.nextBoolean());
Field field = newField("" + k, _TestUtil
- .randomRealisticUnicodeString(random, 128), indexValue[random
- .nextInt(indexValue.length)]);
+ .randomRealisticUnicodeString(random, 128), customType);
doc.add(field);
}
writer.addDocument(doc);
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestRollback.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestRollback.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestRollback.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestRollback.java Mon Aug 15 22:03:41 2011
@@ -19,8 +19,8 @@ package org.apache.lucene.index;
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.FieldType;
+import org.apache.lucene.document.TextField;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
@@ -30,9 +30,12 @@ public class TestRollback extends Lucene
public void testRollbackIntegrityWithBufferFlush() throws Exception {
Directory dir = newDirectory();
RandomIndexWriter rw = new RandomIndexWriter(random, dir);
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ customType.setOmitNorms(true);
for (int i = 0; i < 5; i++) {
Document doc = new Document();
- doc.add(newField("pk", Integer.toString(i), Store.YES, Index.ANALYZED_NO_NORMS));
+ doc.add(newField("pk", Integer.toString(i), customType));
rw.addDocument(doc);
}
rw.close();
@@ -43,9 +46,15 @@ public class TestRollback extends Lucene
for (int i = 0; i < 3; i++) {
Document doc = new Document();
String value = Integer.toString(i);
+<<<<<<<
doc.add(newField("pk", value, Store.YES, Index.ANALYZED_NO_NORMS));
doc.add(newField("text", "foo", Store.YES, Index.ANALYZED_NO_NORMS));
w.updateDocument(new Term("pk", value), doc);
+=======
+ doc.add(newField("pk", value, customType));
+ doc.add(newField("text", "foo", customType));
+ w.updateDocument(pkTerm.createTerm(value), doc);
+>>>>>>>
}
w.rollback();
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestRollingUpdates.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestRollingUpdates.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestRollingUpdates.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestRollingUpdates.java Mon Aug 15 22:03:41 2011
@@ -19,8 +19,11 @@ package org.apache.lucene.index;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.*;
+<<<<<<<
import org.apache.lucene.document.Field.Index;
import org.apache.lucene.index.codecs.CodecProvider;
+=======
+>>>>>>>
import org.apache.lucene.store.*;
import org.apache.lucene.util.*;
import org.junit.Test;
@@ -55,7 +58,7 @@ public class TestRollingUpdates extends
} else {
id++;
}
- doc.getField("docid").setValue(myID);
+ ((Field) doc.getField("docid")).setValue(myID);
w.updateDocument(new Term("docid", myID), doc);
if (docIter >= SIZE && random.nextInt(50) == 17) {
@@ -130,7 +133,7 @@ public class TestRollingUpdates extends
IndexReader open = null;
for (int i = 0; i < num; i++) {
Document doc = new Document();// docs.nextDoc();
- doc.add(newField("id", "test", Index.NOT_ANALYZED));
+ doc.add(newField("id", "test", StringField.TYPE_UNSTORED));
writer.updateDocument(new Term("id", "test"), doc);
if (random.nextInt(3) == 0) {
if (open == null) {
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSameTokenSamePosition.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSameTokenSamePosition.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSameTokenSamePosition.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSameTokenSamePosition.java Mon Aug 15 22:03:41 2011
@@ -27,6 +27,8 @@ 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.FieldType;
+import org.apache.lucene.document.TextField;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
@@ -41,8 +43,9 @@ public class TestSameTokenSamePosition e
Directory dir = newDirectory();
RandomIndexWriter riw = new RandomIndexWriter(random, dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new BugReproAnalyzer()));
Document doc = new Document();
- doc.add(new Field("eng", "Six drunken" /*This shouldn't matter. */,
- Field.Store.YES, Field.Index.ANALYZED));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ doc.add(new Field("eng", customType, "Six drunken" /*This shouldn't matter. */));
riw.addDocument(doc);
riw.close();
dir.close();
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSegmentInfo.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSegmentInfo.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSegmentInfo.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSegmentInfo.java Mon Aug 15 22:03:41 2011
@@ -3,8 +3,8 @@ package org.apache.lucene.index;
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.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
@@ -33,7 +33,9 @@ public class TestSegmentInfo extends Luc
IndexWriter writer = new IndexWriter(dir, conf);
writer.setInfoStream(VERBOSE ? System.out : null);
Document doc = new Document();
- doc.add(new Field("a", "value", Store.YES, Index.ANALYZED));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ customType.setStored(true);
+ doc.add(new Field("a", customType, "value"));
writer.addDocument(doc);
writer.close();
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSegmentMerger.java Mon Aug 15 22:03:41 2011
@@ -23,9 +23,7 @@ import org.apache.lucene.store.Directory
import org.apache.lucene.store.IOContext;
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.TextField;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.util.BytesRef;
@@ -142,7 +140,7 @@ public class TestSegmentMerger extends L
// Create an index w/ .del file
w.addDocument(new Document());
Document doc = new Document();
- doc.add(new Field("c", "test", Store.NO, Index.ANALYZED));
+ doc.add(new TextField("c", "test"));
w.addDocument(doc);
w.commit();
w.deleteDocuments(new Term("c", "test"));
@@ -160,7 +158,7 @@ public class TestSegmentMerger extends L
// Create an index w/ .s*
w = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.CREATE));
doc = new Document();
- doc.add(new Field("c", "test", Store.NO, Index.ANALYZED));
+ doc.add(new TextField("c", "test"));
w.addDocument(doc);
w.close();
IndexReader r = IndexReader.open(dir, false);
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSegmentReader.java Mon Aug 15 22:03:41 2011
@@ -26,7 +26,6 @@ import org.apache.lucene.util.LuceneTest
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Fieldable;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IOContext.Context;
@@ -68,8 +67,8 @@ public class TestSegmentReader extends L
//There are 2 unstored fields on the document that are not preserved across writing
assertTrue(DocHelper.numFields(result) == DocHelper.numFields(testDoc) - DocHelper.unstored.size());
- List<Fieldable> fields = result.getFields();
- for (final Fieldable field : fields ) {
+ List<IndexableField> fields = result.getFields();
+ for (final IndexableField field : fields ) {
assertTrue(field != null);
assertTrue(DocHelper.nameValues.containsKey(field.name()));
}
@@ -176,9 +175,9 @@ public class TestSegmentReader extends L
public static void checkNorms(IndexReader reader) throws IOException {
// test omit norms
for (int i=0; i<DocHelper.fields.length; i++) {
- Fieldable f = DocHelper.fields[i];
- if (f.isIndexed()) {
- assertEquals(reader.hasNorms(f.name()), !f.getOmitNorms());
+ IndexableField f = DocHelper.fields[i];
+ if (f.indexed()) {
+ assertEquals(reader.hasNorms(f.name()), !f.omitNorms());
assertEquals(reader.hasNorms(f.name()), !DocHelper.noNorms.containsKey(f.name()));
if (!reader.hasNorms(f.name())) {
// test for norms of null
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSegmentTermDocs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSegmentTermDocs.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSegmentTermDocs.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSegmentTermDocs.java Mon Aug 15 22:03:41 2011
@@ -22,7 +22,7 @@ import org.apache.lucene.store.Directory
import org.apache.lucene.store.IOContext;
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.util.BytesRef;
import java.io.IOException;
@@ -261,7 +261,7 @@ public class TestSegmentTermDocs extends
private 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);
}
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSegmentTermEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSegmentTermEnum.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSegmentTermEnum.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSegmentTermEnum.java Mon Aug 15 22:03:41 2011
@@ -24,7 +24,7 @@ import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util._TestUtil;
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.store.Directory;
@@ -134,7 +134,7 @@ public class TestSegmentTermEnum extends
private 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);
}
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestSnapshotDeletionPolicy.java Mon Aug 15 22:03:41 2011
@@ -23,7 +23,8 @@ import java.util.Random;
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.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
@@ -115,7 +116,12 @@ public class TestSnapshotDeletionPolicy
@Override
public void run() {
Document doc = new Document();
- doc.add(newField("content", "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("content", "aaa", customType));
do {
for(int i=0;i<27;i++) {
try {
@@ -156,7 +162,12 @@ public class TestSnapshotDeletionPolicy
// final segment, so deletion policy has a chance to
// delete again:
Document doc = new Document();
- doc.add(newField("content", "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("content", "aaa", customType));
writer.addDocument(doc);
// Make sure we don't have any leftover files in the
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestStressAdvance.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestStressAdvance.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestStressAdvance.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestStressAdvance.java Mon Aug 15 22:03:41 2011
@@ -36,9 +36,11 @@ public class TestStressAdvance extends L
RandomIndexWriter w = new RandomIndexWriter(random, dir);
final Set<Integer> aDocs = new HashSet<Integer>();
final Document doc = new Document();
- final Field f = newField("field", "", Field.Index.NOT_ANALYZED_NO_NORMS);
+ FieldType customType = new FieldType(StringField.TYPE_UNSTORED);
+ customType.setStored(true);
+ final Field f = newField("field", "", StringField.TYPE_UNSTORED);
doc.add(f);
- final Field idField = newField("id", "", Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS);
+ final Field idField = newField("id", "", customType);
doc.add(idField);
int num = atLeast(4097);
for(int id=0;id<num;id++) {
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestStressIndexing.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestStressIndexing.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestStressIndexing.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestStressIndexing.java Mon Aug 15 22:03:41 2011
@@ -75,11 +75,13 @@ public class TestStressIndexing extends
@Override
public void doWork() throws Exception {
// Add 10 docs:
+ FieldType customType = new FieldType(StringField.TYPE_UNSTORED);
+ customType.setStored(true);
for(int j=0; j<10; j++) {
Document d = new Document();
int n = random.nextInt();
- d.add(newField("id", Integer.toString(nextID++), Field.Store.YES, Field.Index.NOT_ANALYZED));
- d.add(newField("contents", English.intToEnglish(n), Field.Store.NO, Field.Index.ANALYZED));
+ d.add(newField("id", Integer.toString(nextID++), customType));
+ d.add(newField("contents", English.intToEnglish(n), TextField.TYPE_UNSTORED));
writer.addDocument(d);
}
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestStressIndexing2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestStressIndexing2.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestStressIndexing2.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestStressIndexing2.java Mon Aug 15 22:03:41 2011
@@ -17,6 +17,7 @@ package org.apache.lucene.index;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
@@ -29,9 +30,11 @@ import org.apache.lucene.util.*;
import junit.framework.Assert;
import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.index.IndexableField;
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.TextField;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.Directory;
@@ -130,10 +133,15 @@ public class TestStressIndexing2 extends
static Term idTerm = new Term("id","");
IndexingThread[] threads;
- static Comparator<Fieldable> fieldNameComparator = new Comparator<Fieldable>() {
- public int compare(Fieldable o1, Fieldable o2) {
- return o1.name().compareTo(o2.name());
- }
+ static Comparator<IndexableField> fieldNameComparator = new Comparator<IndexableField>() {
+ public int compare(IndexableField o1, IndexableField o2) {
+ return o1.name().compareTo(o2.name());
+ }
+ };
+ static Comparator<IndexableField> fieldNameComparator2 = new Comparator<IndexableField>() {
+ public int compare(IndexableField o1, IndexableField o2) {
+ return o1.name().compareTo(o2.name());
+ }
};
// This test avoids using any extra synchronization in the multiple
@@ -249,13 +257,13 @@ public class TestStressIndexing2 extends
Iterator<Document> iter = docs.values().iterator();
while (iter.hasNext()) {
Document d = iter.next();
- ArrayList<Fieldable> fields = new ArrayList<Fieldable>();
+ ArrayList<IndexableField> fields = new ArrayList<IndexableField>();
fields.addAll(d.getFields());
// put fields in same order each time
- Collections.sort(fields, fieldNameComparator);
+ Collections.sort(fields, fieldNameComparator2);
Document d1 = new Document();
- d1.setBoost(d.getBoost());
+ //d1.setBoost(d.getBoost());
for (int i=0; i<fields.size(); i++) {
d1.add(fields.get(i));
}
@@ -508,8 +516,8 @@ public class TestStressIndexing2 extends
}
public static void verifyEquals(Document d1, Document d2) {
- List<Fieldable> ff1 = d1.getFields();
- List<Fieldable> ff2 = d2.getFields();
+ List<IndexableField> ff1 = d1.getFields();
+ List<IndexableField> ff2 = d2.getFields();
Collections.sort(ff1, fieldNameComparator);
Collections.sort(ff2, fieldNameComparator);
@@ -517,10 +525,10 @@ public class TestStressIndexing2 extends
assertEquals(ff1 + " : " + ff2, ff1.size(), ff2.size());
for (int i=0; i<ff1.size(); i++) {
- Fieldable f1 = ff1.get(i);
- Fieldable f2 = ff2.get(i);
- if (f1.isBinary()) {
- assert(f2.isBinary());
+ IndexableField f1 = ff1.get(i);
+ IndexableField f2 = ff2.get(i);
+ if (f1.binaryValue(null) != null) {
+ assert(f2.binaryValue(null) != null);
} else {
String s1 = f1.stringValue();
String s2 = f2.stringValue();
@@ -666,48 +674,70 @@ public class TestStressIndexing2 extends
public void indexDoc() throws IOException {
Document d = new Document();
+ FieldType customType1 = new FieldType(TextField.TYPE_UNSTORED);
+ customType1.setStored(true);
+ customType1.setTokenized(false);
+ customType1.setOmitNorms(true);
+
ArrayList<Field> fields = new ArrayList<Field>();
String idString = getIdString();
+<<<<<<<
Field idField = newField("id", idString, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS);
+=======
+ Field idField = newField(idTerm.field(), idString, customType1);
+>>>>>>>
fields.add(idField);
int nFields = nextInt(maxFields);
for (int i=0; i<nFields; i++) {
- Field.TermVector tvVal = Field.TermVector.NO;
+ FieldType customType = new FieldType();
switch (nextInt(4)) {
case 0:
- tvVal = Field.TermVector.NO;
break;
case 1:
- tvVal = Field.TermVector.YES;
+ customType.setStoreTermVectors(true);
break;
case 2:
- tvVal = Field.TermVector.WITH_POSITIONS;
+ customType.setStoreTermVectors(true);
+ customType.setStoreTermVectorPositions(true);
break;
case 3:
- tvVal = Field.TermVector.WITH_POSITIONS_OFFSETS;
+ customType.setStoreTermVectors(true);
+ customType.setStoreTermVectorOffsets(true);
break;
}
switch (nextInt(4)) {
case 0:
- fields.add(newField("f" + nextInt(100), getString(1), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS, tvVal));
+ customType.setStored(true);
+ customType.setOmitNorms(true);
+ customType.setIndexed(true);
+ fields.add(newField("f" + nextInt(100), getString(1), customType));
break;
case 1:
- fields.add(newField("f" + nextInt(100), getString(0), Field.Store.NO, Field.Index.ANALYZED, tvVal));
+ customType.setIndexed(true);
+ customType.setTokenized(true);
+ fields.add(newField("f" + nextInt(100), getString(0), customType));
break;
case 2:
- fields.add(newField("f" + nextInt(100), getString(0), Field.Store.YES, Field.Index.NO, Field.TermVector.NO));
+ customType.setStored(true);
+ customType.setStoreTermVectors(false);
+ customType.setStoreTermVectorOffsets(false);
+ customType.setStoreTermVectorPositions(false);
+ fields.add(newField("f" + nextInt(100), getString(0), customType));
break;
case 3:
- fields.add(newField("f" + nextInt(100), getString(bigFieldSize), Field.Store.YES, Field.Index.ANALYZED, tvVal));
+ customType.setStored(true);
+ customType.setIndexed(true);
+ customType.setTokenized(true);
+ fields.add(newField("f" + nextInt(100), getString(bigFieldSize), customType));
break;
}
}
if (sameFieldOrder) {
- Collections.sort(fields, fieldNameComparator);
+ Collections.sort(fields, fieldNameComparator2);
} else {
// random placement of id field also
Collections.swap(fields,nextInt(fields.size()), 0);
Modified: lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java?rev=1158029&r1=1158028&r2=1158029&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/lucene/src/test/org/apache/lucene/index/TestTermVectorsReader.java Mon Aug 15 22:03:41 2011
@@ -31,6 +31,8 @@ import org.apache.lucene.analysis.tokena
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
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.store.Directory;
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IOContext.Context;
@@ -101,16 +103,24 @@ public class TestTermVectorsReader exten
Document doc = new Document();
for(int i=0;i<testFields.length;i++) {
- final Field.TermVector tv;
- if (testFieldsStorePos[i] && testFieldsStoreOff[i])
- tv = Field.TermVector.WITH_POSITIONS_OFFSETS;
- else if (testFieldsStorePos[i] && !testFieldsStoreOff[i])
- tv = Field.TermVector.WITH_POSITIONS;
- else if (!testFieldsStorePos[i] && testFieldsStoreOff[i])
- tv = Field.TermVector.WITH_OFFSETS;
- else
- tv = Field.TermVector.YES;
- doc.add(new Field(testFields[i], "", Field.Store.NO, Field.Index.ANALYZED, tv));
+ FieldType customType = new FieldType(TextField.TYPE_UNSTORED);
+ if (testFieldsStorePos[i] && testFieldsStoreOff[i]) {
+ customType.setStoreTermVectors(true);
+ customType.setStoreTermVectorPositions(true);
+ customType.setStoreTermVectorOffsets(true);
+ }
+ else if (testFieldsStorePos[i] && !testFieldsStoreOff[i]) {
+ customType.setStoreTermVectors(true);
+ customType.setStoreTermVectorPositions(true);
+ }
+ else if (!testFieldsStorePos[i] && testFieldsStoreOff[i]) {
+ customType.setStoreTermVectors(true);
+ customType.setStoreTermVectorOffsets(true);
+ }
+ else {
+ customType.setStoreTermVectors(true);
+ }
+ doc.add(new Field(testFields[i], customType, ""));
}
//Create 5 documents for testing, they all have the same