diff --git a/lucene/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java b/lucene/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java index c3597d6d0b3..8be566a1c99 100644 --- a/lucene/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java +++ b/lucene/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java @@ -108,8 +108,8 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase { IndexWriter writer = new IndexWriter(ramdir, new IndexWriterConfig(TEST_VERSION_CURRENT, analyzer).setCodecProvider(_TestUtil.alwaysCodec("Standard"))); Document doc = new Document(); - Field field1 = new Field("foo", fooField.toString(), Field.Store.NO, Field.Index.ANALYZED); - Field field2 = new Field("term", termField.toString(), Field.Store.NO, Field.Index.ANALYZED); + Field field1 = newField("foo", fooField.toString(), Field.Store.NO, Field.Index.ANALYZED); + Field field2 = newField("term", termField.toString(), Field.Store.NO, Field.Index.ANALYZED); doc.add(field1); doc.add(field2); writer.addDocument(doc); diff --git a/lucene/contrib/misc/src/test/org/apache/lucene/index/TestFieldNormModifier.java b/lucene/contrib/misc/src/test/org/apache/lucene/index/TestFieldNormModifier.java index cb8624e8362..4481c418455 100644 --- a/lucene/contrib/misc/src/test/org/apache/lucene/index/TestFieldNormModifier.java +++ b/lucene/contrib/misc/src/test/org/apache/lucene/index/TestFieldNormModifier.java @@ -62,13 +62,13 @@ public class TestFieldNormModifier extends LuceneTestCase { for (int i = 0; i < NUM_DOCS; i++) { Document d = new Document(); - d.add(new Field("field", "word", Field.Store.YES, Field.Index.ANALYZED)); - d.add(new Field("nonorm", "word", Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS)); - d.add(new Field("untokfield", "20061212 20071212", Field.Store.YES, Field.Index.ANALYZED)); + d.add(newField("field", "word", Field.Store.YES, Field.Index.ANALYZED)); + d.add(newField("nonorm", "word", Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS)); + d.add(newField("untokfield", "20061212 20071212", Field.Store.YES, Field.Index.ANALYZED)); for (int j = 1; j <= i; j++) { - d.add(new Field("field", "crap", Field.Store.YES, Field.Index.ANALYZED)); - d.add(new Field("nonorm", "more words", Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS)); + d.add(newField("field", "crap", Field.Store.YES, Field.Index.ANALYZED)); + d.add(newField("nonorm", "more words", Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS)); } writer.addDocument(d); } diff --git a/lucene/contrib/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java b/lucene/contrib/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java index 1d2fa6729ff..86b03aa05dc 100644 --- a/lucene/contrib/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java +++ b/lucene/contrib/misc/src/test/org/apache/lucene/index/TestMultiPassIndexSplitter.java @@ -36,8 +36,8 @@ public class TestMultiPassIndexSplitter extends LuceneTestCase { Document doc; for (int i = 0; i < NUM_DOCS; i++) { doc = new Document(); - doc.add(new Field("id", i + "", Field.Store.YES, Field.Index.NOT_ANALYZED)); - doc.add(new Field("f", i + " " + i, Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("id", i + "", Field.Store.YES, Field.Index.NOT_ANALYZED)); + doc.add(newField("f", i + " " + i, Field.Store.YES, Field.Index.ANALYZED)); w.addDocument(doc); } w.close(); diff --git a/lucene/contrib/misc/src/test/org/apache/lucene/index/TestTermVectorAccessor.java b/lucene/contrib/misc/src/test/org/apache/lucene/index/TestTermVectorAccessor.java index c58f500e4eb..65e6bca1d66 100644 --- a/lucene/contrib/misc/src/test/org/apache/lucene/index/TestTermVectorAccessor.java +++ b/lucene/contrib/misc/src/test/org/apache/lucene/index/TestTermVectorAccessor.java @@ -30,33 +30,33 @@ public class TestTermVectorAccessor extends LuceneTestCase { Document doc; doc = new Document(); - doc.add(new Field("a", "a b a c a d a e a f a g a h a", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); - doc.add(new Field("b", "a b c b d b e b f b g b h b", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); - doc.add(new Field("c", "a c b c d c e c f c g c h c", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); + doc.add(newField("a", "a b a c a d a e a f a g a h a", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); + doc.add(newField("b", "a b c b d b e b f b g b h b", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); + doc.add(newField("c", "a c b c d c e c f c g c h c", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); iw.addDocument(doc); doc = new Document(); - doc.add(new Field("a", "a b a c a d a e a f a g a h a", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS)); - doc.add(new Field("b", "a b c b d b e b f b g b h b", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS)); - doc.add(new Field("c", "a c b c d c e c f c g c h c", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS)); + doc.add(newField("a", "a b a c a d a e a f a g a h a", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS)); + doc.add(newField("b", "a b c b d b e b f b g b h b", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS)); + doc.add(newField("c", "a c b c d c e c f c g c h c", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS)); iw.addDocument(doc); doc = new Document(); - doc.add(new Field("a", "a b a c a d a e a f a g a h a", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.YES)); - doc.add(new Field("b", "a b c b d b e b f b g b h b", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.YES)); - doc.add(new Field("c", "a c b c d c e c f c g c h c", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.YES)); + doc.add(newField("a", "a b a c a d a e a f a g a h a", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.YES)); + doc.add(newField("b", "a b c b d b e b f b g b h b", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.YES)); + doc.add(newField("c", "a c b c d c e c f c g c h c", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.YES)); iw.addDocument(doc); doc = new Document(); - doc.add(new Field("a", "a b a c a d a e a f a g a h a", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.NO)); - doc.add(new Field("b", "a b c b d b e b f b g b h b", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.NO)); - doc.add(new Field("c", "a c b c d c e c f c g c h c", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.NO)); + doc.add(newField("a", "a b a c a d a e a f a g a h a", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.NO)); + doc.add(newField("b", "a b c b d b e b f b g b h b", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.NO)); + doc.add(newField("c", "a c b c d c e c f c g c h c", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.NO)); iw.addDocument(doc); doc = new Document(); - doc.add(new Field("a", "a b a c a d a e a f a g a h a", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); - doc.add(new Field("b", "a b c b d b e b f b g b h b", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.NO)); - doc.add(new Field("c", "a c b c d c e c f c g c h c", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.YES)); + doc.add(newField("a", "a b a c a d a e a f a g a h a", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); + doc.add(newField("b", "a b c b d b e b f b g b h b", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.NO)); + doc.add(newField("c", "a c b c d c e c f c g c h c", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.YES)); iw.addDocument(doc); iw.close(); diff --git a/lucene/contrib/misc/src/test/org/apache/lucene/index/codecs/appending/TestAppendingCodec.java b/lucene/contrib/misc/src/test/org/apache/lucene/index/codecs/appending/TestAppendingCodec.java index 3e161547139..fab18ed029d 100644 --- a/lucene/contrib/misc/src/test/org/apache/lucene/index/codecs/appending/TestAppendingCodec.java +++ b/lucene/contrib/misc/src/test/org/apache/lucene/index/codecs/appending/TestAppendingCodec.java @@ -143,7 +143,7 @@ public class TestAppendingCodec extends LuceneTestCase { ((LogMergePolicy)cfg.getMergePolicy()).setUseCompoundDocStore(false); IndexWriter writer = new IndexWriter(dir, cfg); Document doc = new Document(); - doc.add(new Field("f", text, Store.YES, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS)); + doc.add(newField("f", text, Store.YES, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS)); writer.addDocument(doc); writer.commit(); writer.addDocument(doc); diff --git a/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestHighFreqTerms.java b/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestHighFreqTerms.java index c4c96be0916..abbf3b4a19f 100644 --- a/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestHighFreqTerms.java +++ b/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestHighFreqTerms.java @@ -189,7 +189,7 @@ public class TestHighFreqTerms extends LuceneTestCase { } /********************Testing Utils**********************************/ - private static void indexDocs(IndexWriter writer) throws Exception { + private void indexDocs(IndexWriter writer) throws Exception { /** * Generate 10 documents where term n has a docFreq of n and a totalTermFreq of n*2 (squared). @@ -198,9 +198,9 @@ public class TestHighFreqTerms extends LuceneTestCase { Document doc = new Document(); String content = getContent(i); - doc.add(new Field("FIELD_1", content, Field.Store.YES,Field.Index.ANALYZED, Field.TermVector.NO)); + doc.add(newField("FIELD_1", content, Field.Store.YES,Field.Index.ANALYZED, Field.TermVector.NO)); //add a different field - doc.add(new Field("different_field", "diff", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO)); + doc.add(newField("different_field", "diff", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO)); writer.addDocument(doc); } @@ -208,7 +208,7 @@ public class TestHighFreqTerms extends LuceneTestCase { //highest freq terms for a specific field. for (int i = 1; i <= 10; i++) { Document doc = new Document(); - doc.add(new Field("different_field", "diff", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO)); + doc.add(newField("different_field", "diff", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO)); writer.addDocument(doc); } // add some docs where tf < df so we can see if sorting works @@ -219,7 +219,7 @@ public class TestHighFreqTerms extends LuceneTestCase { for (int i = 0; i < highTF; i++) { content += "highTF "; } - doc.add(new Field("FIELD_1", content, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO)); + doc.add(newField("FIELD_1", content, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO)); writer.addDocument(doc); // highTF medium df =5 int medium_df = 5; @@ -230,7 +230,7 @@ public class TestHighFreqTerms extends LuceneTestCase { for (int j = 0; j < tf; j++) { newcontent += "highTFmedDF "; } - newdoc.add(new Field("FIELD_1", newcontent, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO)); + newdoc.add(newField("FIELD_1", newcontent, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO)); writer.addDocument(newdoc); } // add a doc with high tf in field different_field @@ -240,7 +240,7 @@ public class TestHighFreqTerms extends LuceneTestCase { for (int i = 0; i < targetTF; i++) { content += "TF150 "; } - doc.add(new Field("different_field", content, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO)); + doc.add(newField("different_field", content, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.NO)); writer.addDocument(doc); writer.close(); diff --git a/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestLengthNormModifier.java b/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestLengthNormModifier.java index df2bbc179d2..d483cf28be5 100644 --- a/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestLengthNormModifier.java +++ b/lucene/contrib/misc/src/test/org/apache/lucene/misc/TestLengthNormModifier.java @@ -65,15 +65,15 @@ public class TestLengthNormModifier extends LuceneTestCase { for (int i = 0; i < NUM_DOCS; i++) { Document d = new Document(); - d.add(new Field("field", "word", + d.add(newField("field", "word", Field.Store.YES, Field.Index.ANALYZED)); - d.add(new Field("nonorm", "word", + d.add(newField("nonorm", "word", Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS)); for (int j = 1; j <= i; j++) { - d.add(new Field("field", "crap", + d.add(newField("field", "crap", Field.Store.YES, Field.Index.ANALYZED)); - d.add(new Field("nonorm", "more words", + d.add(newField("nonorm", "more words", Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS)); } writer.addDocument(d); diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/BooleanFilterTest.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/BooleanFilterTest.java index 9474f5351c0..b0444fda8aa 100644 --- a/lucene/contrib/queries/src/test/org/apache/lucene/search/BooleanFilterTest.java +++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/BooleanFilterTest.java @@ -62,10 +62,10 @@ public class BooleanFilterTest extends LuceneTestCase { private void addDoc(RandomIndexWriter writer, String accessRights, String price, String date, String inStock) throws IOException { Document doc=new Document(); - doc.add(new Field("accessRights",accessRights,Field.Store.YES,Field.Index.ANALYZED)); - doc.add(new Field("price",price,Field.Store.YES,Field.Index.ANALYZED)); - doc.add(new Field("date",date,Field.Store.YES,Field.Index.ANALYZED)); - doc.add(new Field("inStock",inStock,Field.Store.YES,Field.Index.ANALYZED)); + doc.add(newField("accessRights",accessRights,Field.Store.YES,Field.Index.ANALYZED)); + doc.add(newField("price",price,Field.Store.YES,Field.Index.ANALYZED)); + doc.add(newField("date",date,Field.Store.YES,Field.Index.ANALYZED)); + doc.add(newField("inStock",inStock,Field.Store.YES,Field.Index.ANALYZED)); writer.addDocument(doc); } diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/ChainedFilterTest.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/ChainedFilterTest.java index 632674eeb0a..dbfabb13fa8 100644 --- a/lucene/contrib/queries/src/test/org/apache/lucene/search/ChainedFilterTest.java +++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/ChainedFilterTest.java @@ -63,9 +63,9 @@ public class ChainedFilterTest extends LuceneTestCase { for (int i = 0; i < MAX; i++) { Document doc = new Document(); - doc.add(new Field("key", "" + (i + 1), Field.Store.YES, Field.Index.NOT_ANALYZED)); - doc.add(new Field("owner", (i < MAX / 2) ? "bob" : "sue", Field.Store.YES, Field.Index.NOT_ANALYZED)); - doc.add(new Field("date", cal.getTime().toString(), Field.Store.YES, Field.Index.NOT_ANALYZED)); + doc.add(newField("key", "" + (i + 1), Field.Store.YES, Field.Index.NOT_ANALYZED)); + doc.add(newField("owner", (i < MAX / 2) ? "bob" : "sue", Field.Store.YES, Field.Index.NOT_ANALYZED)); + doc.add(newField("date", cal.getTime().toString(), Field.Store.YES, Field.Index.NOT_ANALYZED)); writer.addDocument(doc); cal.add(Calendar.DATE, 1); diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/DuplicateFilterTest.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/DuplicateFilterTest.java index 1117e2da88d..cde625d237d 100644 --- a/lucene/contrib/queries/src/test/org/apache/lucene/search/DuplicateFilterTest.java +++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/DuplicateFilterTest.java @@ -75,9 +75,9 @@ public class DuplicateFilterTest extends LuceneTestCase { private void addDoc(RandomIndexWriter writer, String url, String text, String date) throws IOException { Document doc=new Document(); - doc.add(new Field(KEY_FIELD,url,Field.Store.YES,Field.Index.NOT_ANALYZED)); - doc.add(new Field("text",text,Field.Store.YES,Field.Index.ANALYZED)); - doc.add(new Field("date",date,Field.Store.YES,Field.Index.ANALYZED)); + doc.add(newField(KEY_FIELD,url,Field.Store.YES,Field.Index.NOT_ANALYZED)); + doc.add(newField("text",text,Field.Store.YES,Field.Index.ANALYZED)); + doc.add(newField("date",date,Field.Store.YES,Field.Index.ANALYZED)); writer.addDocument(doc); } diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/FuzzyLikeThisQueryTest.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/FuzzyLikeThisQueryTest.java index 269a50dc68b..37532cc155f 100644 --- a/lucene/contrib/queries/src/test/org/apache/lucene/search/FuzzyLikeThisQueryTest.java +++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/FuzzyLikeThisQueryTest.java @@ -65,8 +65,8 @@ public class FuzzyLikeThisQueryTest extends LuceneTestCase { private void addDoc(RandomIndexWriter writer, String name, String id) throws IOException { Document doc=new Document(); - doc.add(new Field("name",name,Field.Store.YES,Field.Index.ANALYZED)); - doc.add(new Field("id",id,Field.Store.YES,Field.Index.ANALYZED)); + doc.add(newField("name",name,Field.Store.YES,Field.Index.ANALYZED)); + doc.add(newField("id",id,Field.Store.YES,Field.Index.ANALYZED)); writer.addDocument(doc); } diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/TermsFilterTest.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/TermsFilterTest.java index 1f0b4bea116..24ea7c348b7 100644 --- a/lucene/contrib/queries/src/test/org/apache/lucene/search/TermsFilterTest.java +++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/TermsFilterTest.java @@ -57,7 +57,7 @@ public class TermsFilterTest extends LuceneTestCase { for (int i = 0; i < 100; i++) { Document doc=new Document(); int term=i*10; //terms are units of 10; - doc.add(new Field(fieldName,""+term,Field.Store.YES,Field.Index.NOT_ANALYZED)); + doc.add(newField(fieldName,""+term,Field.Store.YES,Field.Index.NOT_ANALYZED)); w.addDocument(doc); } IndexReader mainReader = w.getReader(); diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestRegexQuery.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestRegexQuery.java index 5246a955dae..ca4058aa063 100644 --- a/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestRegexQuery.java +++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestRegexQuery.java @@ -43,7 +43,7 @@ public class TestRegexQuery extends LuceneTestCase { directory = newDirectory(); RandomIndexWriter writer = new RandomIndexWriter(random, directory); Document doc = new Document(); - doc.add(new Field(FN, "the quick brown fox jumps over the lazy dog", Field.Store.NO, Field.Index.ANALYZED)); + doc.add(newField(FN, "the quick brown fox jumps over the lazy dog", Field.Store.NO, Field.Index.ANALYZED)); writer.addDocument(doc); reader = writer.getReader(); writer.close(); diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java index 05312f19885..d161fefa3a6 100644 --- a/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java +++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java @@ -59,15 +59,15 @@ public class TestSpanRegexQuery extends LuceneTestCase { IndexWriter writer = new IndexWriter(directory, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())); Document doc = new Document(); - // doc.add(new Field("field", "the quick brown fox jumps over the lazy dog", + // doc.add(newField("field", "the quick brown fox jumps over the lazy dog", // Field.Store.NO, Field.Index.ANALYZED)); // writer.addDocument(doc); // doc = new Document(); - doc.add(new Field("field", "auto update", Field.Store.NO, + doc.add(newField("field", "auto update", Field.Store.NO, Field.Index.ANALYZED)); writer.addDocument(doc); doc = new Document(); - doc.add(new Field("field", "first auto update", Field.Store.NO, + doc.add(newField("field", "first auto update", Field.Store.NO, Field.Index.ANALYZED)); writer.addDocument(doc); writer.optimize(); @@ -115,12 +115,12 @@ public class TestSpanRegexQuery extends LuceneTestCase { LockObtainFailedException, IOException { // creating a document to store Document lDoc = new Document(); - lDoc.add(new Field("field", "a1 b1", Field.Store.NO, + lDoc.add(newField("field", "a1 b1", Field.Store.NO, Field.Index.ANALYZED_NO_NORMS)); // creating a document to store Document lDoc2 = new Document(); - lDoc2.add(new Field("field", "a2 b2", Field.Store.NO, + lDoc2.add(newField("field", "a2 b2", Field.Store.NO, Field.Index.ANALYZED_NO_NORMS)); // creating first index writer diff --git a/lucene/contrib/queries/src/test/org/apache/lucene/search/similar/TestMoreLikeThis.java b/lucene/contrib/queries/src/test/org/apache/lucene/search/similar/TestMoreLikeThis.java index d903789ecbf..5efc85cae01 100644 --- a/lucene/contrib/queries/src/test/org/apache/lucene/search/similar/TestMoreLikeThis.java +++ b/lucene/contrib/queries/src/test/org/apache/lucene/search/similar/TestMoreLikeThis.java @@ -66,7 +66,7 @@ public class TestMoreLikeThis extends LuceneTestCase { private void addDoc(RandomIndexWriter writer, String text) throws IOException { Document doc = new Document(); - doc.add(new Field("text", text, Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("text", text, Field.Store.YES, Field.Index.ANALYZED)); writer.addDocument(doc); } diff --git a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/complexPhrase/TestComplexPhraseQuery.java b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/complexPhrase/TestComplexPhraseQuery.java index 7e2e758897d..b2bc9db52ec 100644 --- a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/complexPhrase/TestComplexPhraseQuery.java +++ b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/complexPhrase/TestComplexPhraseQuery.java @@ -115,9 +115,9 @@ public class TestComplexPhraseQuery extends LuceneTestCase { IndexWriter w = new IndexWriter(rd, newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer)); for (int i = 0; i < docsContent.length; i++) { Document doc = new Document(); - doc.add(new Field("name", docsContent[i].name, Field.Store.YES, + doc.add(newField("name", docsContent[i].name, Field.Store.YES, Field.Index.ANALYZED)); - doc.add(new Field("id", docsContent[i].id, Field.Store.YES, + doc.add(newField("id", docsContent[i].id, Field.Store.YES, Field.Index.ANALYZED)); w.addDocument(doc); } diff --git a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java index efeacb62346..f74727a5a1c 100644 --- a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java +++ b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java @@ -320,7 +320,7 @@ public class TestMultiFieldQPHelper extends LuceneTestCase { Directory ramDir = newDirectory(); IndexWriter iw = new IndexWriter(ramDir, newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer)); Document doc = new Document(); - doc.add(new Field("body", "blah the footest blah", Field.Store.NO, + doc.add(newField("body", "blah the footest blah", Field.Store.NO, Field.Index.ANALYZED)); iw.addDocument(doc); iw.close(); diff --git a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java index 4dc4612b849..aedece380d3 100644 --- a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java +++ b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java @@ -324,7 +324,7 @@ public class TestMultiFieldQueryParserWrapper extends LuceneTestCase { IndexWriter iw = new IndexWriter(ramDir, analyzer, true, IndexWriter.MaxFieldLength.LIMITED); Document doc = new Document(); - doc.add(new Field("body", "blah the footest blah", Field.Store.NO, + doc.add(newField("body", "blah the footest blah", Field.Store.NO, Field.Index.ANALYZED)); iw.addDocument(doc); iw.close(); diff --git a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java index 1a08dfb3d4d..7f48ec9de85 100644 --- a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java +++ b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java @@ -656,7 +656,7 @@ public class TestQPHelper extends LocalizedTestCase { Directory ramDir = newDirectory(); IndexWriter iw = new IndexWriter(ramDir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false))); Document doc = new Document(); - doc.add(new Field("content", "\u0633\u0627\u0628", Field.Store.YES, + doc.add(newField("content", "\u0633\u0627\u0628", Field.Store.YES, Field.Index.NOT_ANALYZED)); iw.addDocument(doc); iw.close(); @@ -1250,13 +1250,13 @@ public class TestQPHelper extends LocalizedTestCase { assertEquals(expected, hits.length); } - private static void addDateDoc(String content, int year, int month, int day, + private void addDateDoc(String content, int year, int month, int day, int hour, int minute, int second, IndexWriter iw) throws IOException { Document d = new Document(); - d.add(new Field("f", content, Field.Store.YES, Field.Index.ANALYZED)); + d.add(newField("f", content, Field.Store.YES, Field.Index.ANALYZED)); Calendar cal = Calendar.getInstance(Locale.ENGLISH); cal.set(year, month - 1, day, hour, minute, second); - d.add(new Field("date", DateField.dateToString(cal.getTime()), + d.add(newField("date", DateField.dateToString(cal.getTime()), Field.Store.YES, Field.Index.NOT_ANALYZED)); iw.addDocument(d); } @@ -1306,7 +1306,7 @@ public class TestQPHelper extends LocalizedTestCase { Directory dir = newDirectory(); IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new CannedAnalyzer())); Document doc = new Document(); - doc.add(new Field("field", "", Field.Store.NO, Field.Index.ANALYZED)); + doc.add(newField("field", "", Field.Store.NO, Field.Index.ANALYZED)); w.addDocument(doc); IndexReader r = w.getReader(); IndexSearcher s = new IndexSearcher(r); diff --git a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java index 83836c8624c..ff8e921d2f7 100644 --- a/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java +++ b/lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java @@ -658,7 +658,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase { IndexWriter iw = new IndexWriter(ramDir, new MockAnalyzer(MockTokenizer.WHITESPACE, false), true, IndexWriter.MaxFieldLength.LIMITED); Document doc = new Document(); - doc.add(new Field("content", "\u0633\u0627\u0628", Field.Store.YES, + doc.add(newField("content", "\u0633\u0627\u0628", Field.Store.YES, Field.Index.NOT_ANALYZED)); iw.addDocument(doc); iw.close(); @@ -1201,13 +1201,13 @@ public class TestQueryParserWrapper extends LocalizedTestCase { assertEquals(expected, hits.length); } - private static void addDateDoc(String content, int year, int month, int day, + private void addDateDoc(String content, int year, int month, int day, int hour, int minute, int second, IndexWriter iw) throws IOException { Document d = new Document(); - d.add(new Field("f", content, Field.Store.YES, Field.Index.ANALYZED)); + d.add(newField("f", content, Field.Store.YES, Field.Index.ANALYZED)); Calendar cal = Calendar.getInstance(Locale.ENGLISH); cal.set(year, month - 1, day, hour, minute, second); - d.add(new Field("date", DateField.dateToString(cal.getTime()), + d.add(newField("date", DateField.dateToString(cal.getTime()), Field.Store.YES, Field.Index.NOT_ANALYZED)); iw.addDocument(d); } diff --git a/lucene/contrib/remote/src/test/org/apache/lucene/search/TestRemoteCachingWrapperFilter.java b/lucene/contrib/remote/src/test/org/apache/lucene/search/TestRemoteCachingWrapperFilter.java index efb7701909a..5ad94c0f454 100644 --- a/lucene/contrib/remote/src/test/org/apache/lucene/search/TestRemoteCachingWrapperFilter.java +++ b/lucene/contrib/remote/src/test/org/apache/lucene/search/TestRemoteCachingWrapperFilter.java @@ -46,15 +46,15 @@ public class TestRemoteCachingWrapperFilter extends RemoteTestCaseJ4 { IndexWriter writer = new IndexWriter(indexStore, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())); Document doc = new Document(); - doc.add(new Field("test", "test text", Field.Store.YES, Field.Index.ANALYZED)); - doc.add(new Field("type", "A", Field.Store.YES, Field.Index.ANALYZED)); - doc.add(new Field("other", "other test text", Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField(random, "test", "test text", Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField(random, "type", "A", Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField(random, "other", "other test text", Field.Store.YES, Field.Index.ANALYZED)); writer.addDocument(doc); //Need a second document to search for doc = new Document(); - doc.add(new Field("test", "test text", Field.Store.YES, Field.Index.ANALYZED)); - doc.add(new Field("type", "B", Field.Store.YES, Field.Index.ANALYZED)); - doc.add(new Field("other", "other test text", Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField(random, "test", "test text", Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField(random, "type", "B", Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField(random, "other", "other test text", Field.Store.YES, Field.Index.ANALYZED)); writer.addDocument(doc); writer.optimize(); writer.close(); diff --git a/lucene/contrib/remote/src/test/org/apache/lucene/search/TestRemoteSearchable.java b/lucene/contrib/remote/src/test/org/apache/lucene/search/TestRemoteSearchable.java index 69ce657c258..00beb6086de 100644 --- a/lucene/contrib/remote/src/test/org/apache/lucene/search/TestRemoteSearchable.java +++ b/lucene/contrib/remote/src/test/org/apache/lucene/search/TestRemoteSearchable.java @@ -45,8 +45,8 @@ public class TestRemoteSearchable extends RemoteTestCaseJ4 { IndexWriter writer = new IndexWriter(indexStore, newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer())); Document doc = new Document(); - doc.add(new Field("test", "test text", Field.Store.YES, Field.Index.ANALYZED)); - doc.add(new Field("other", "other test text", Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField(random, "test", "test text", Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField(random, "other", "other test text", Field.Store.YES, Field.Index.ANALYZED)); writer.addDocument(doc); writer.optimize(); writer.close(); diff --git a/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java b/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java index 83536f2c563..e6b4581f0b9 100644 --- a/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java +++ b/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java @@ -98,14 +98,14 @@ public class TestCartesian extends LuceneTestCase { Document doc = new Document(); - doc.add(new Field("name", name,Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("name", name,Field.Store.YES, Field.Index.ANALYZED)); // convert the lat / long to lucene fields doc.add(new NumericField(latField, Integer.MAX_VALUE, Field.Store.YES, true).setDoubleValue(lat)); doc.add(new NumericField(lngField, Integer.MAX_VALUE, Field.Store.YES, true).setDoubleValue(lng)); // add a default meta field to make searching all documents easy - doc.add(new Field("metafile", "doc",Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("metafile", "doc",Field.Store.YES, Field.Index.ANALYZED)); int ctpsize = ctps.size(); for (int i =0; i < ctpsize; i++){ @@ -114,7 +114,7 @@ public class TestCartesian extends LuceneTestCase { Field.Store.YES, true).setDoubleValue(ctp.getTierBoxId(lat,lng))); - doc.add(new Field(geoHashPrefix, GeoHashUtils.encode(lat,lng), + doc.add(newField(geoHashPrefix, GeoHashUtils.encode(lat,lng), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS)); } diff --git a/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestDistance.java b/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestDistance.java index 3f7543bf0cc..7b2f5fa1639 100644 --- a/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestDistance.java +++ b/lucene/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestDistance.java @@ -60,14 +60,14 @@ public class TestDistance extends LuceneTestCase { Document doc = new Document(); - doc.add(new Field("name", name,Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("name", name,Field.Store.YES, Field.Index.ANALYZED)); // convert the lat / long to lucene fields doc.add(new NumericField(latField, Integer.MAX_VALUE, Field.Store.YES, true).setDoubleValue(lat)); doc.add(new NumericField(lngField, Integer.MAX_VALUE,Field.Store.YES, true).setDoubleValue(lng)); // add a default meta field to make searching all documents easy - doc.add(new Field("metafile", "doc",Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("metafile", "doc",Field.Store.YES, Field.Index.ANALYZED)); writer.addDocument(doc); } diff --git a/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java b/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java index 66241af406e..a8d06c436e2 100644 --- a/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java +++ b/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestLuceneDictionary.java @@ -51,11 +51,11 @@ public class TestLuceneDictionary extends LuceneTestCase { Document doc; doc = new Document(); - doc.add(new Field("aaa", "foo", Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("aaa", "foo", Field.Store.YES, Field.Index.ANALYZED)); writer.addDocument(doc); doc = new Document(); - doc.add(new Field("aaa", "foo", Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("aaa", "foo", Field.Store.YES, Field.Index.ANALYZED)); writer.addDocument(doc); doc = new Document(); @@ -67,7 +67,7 @@ public class TestLuceneDictionary extends LuceneTestCase { writer.addDocument(doc); doc = new Document(); - doc.add(new Field("zzz", "bar", Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("zzz", "bar", Field.Store.YES, Field.Index.ANALYZED)); writer.addDocument(doc); writer.optimize(); diff --git a/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java b/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java index 7becbd2b65c..d7cb5861c4e 100755 --- a/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java +++ b/lucene/contrib/spellchecker/src/test/org/apache/lucene/search/spell/TestSpellChecker.java @@ -58,9 +58,9 @@ public class TestSpellChecker extends LuceneTestCase { for (int i = 0; i < 1000; i++) { Document doc = new Document(); - doc.add(new Field("field1", English.intToEnglish(i), Field.Store.YES, Field.Index.ANALYZED)); - doc.add(new Field("field2", English.intToEnglish(i + 1), Field.Store.YES, Field.Index.ANALYZED)); // + word thousand - doc.add(new Field("field3", "fvei" + (i % 2 == 0 ? " five" : ""), Field.Store.YES, Field.Index.ANALYZED)); // + word thousand + doc.add(newField("field1", English.intToEnglish(i), Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("field2", English.intToEnglish(i + 1), Field.Store.YES, Field.Index.ANALYZED)); // + word thousand + doc.add(newField("field3", "fvei" + (i % 2 == 0 ? " five" : ""), Field.Store.YES, Field.Index.ANALYZED)); // + word thousand writer.addDocument(doc); } writer.close(); diff --git a/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java b/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java index bb0f82003f2..f44a8e3b88f 100644 --- a/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java +++ b/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java @@ -66,8 +66,8 @@ public class TestParser extends LuceneTestCase { String date=line.substring(0,endOfDate).trim(); String content=line.substring(endOfDate).trim(); org.apache.lucene.document.Document doc =new org.apache.lucene.document.Document(); - doc.add(new Field("date",date,Field.Store.YES,Field.Index.ANALYZED)); - doc.add(new Field("contents",content,Field.Store.YES,Field.Index.ANALYZED)); + doc.add(newField("date",date,Field.Store.YES,Field.Index.ANALYZED)); + doc.add(newField("contents",content,Field.Store.YES,Field.Index.ANALYZED)); NumericField numericField = new NumericField("date2"); numericField.setIntValue(Integer.valueOf(date)); doc.add(numericField); diff --git a/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestQueryTemplateManager.java b/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestQueryTemplateManager.java index 621a3f6b02c..d0256149190 100644 --- a/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestQueryTemplateManager.java +++ b/lucene/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestQueryTemplateManager.java @@ -126,7 +126,7 @@ public class TestQueryTemplateManager extends LuceneTestCase { if(st.hasMoreTokens()) { String value=st.nextToken().trim(); - result.add(new Field(name,value,Field.Store.YES,Field.Index.ANALYZED)); + result.add(newField(name,value,Field.Store.YES,Field.Index.ANALYZED)); } } return result; diff --git a/lucene/src/test/org/apache/lucene/TestDemo.java b/lucene/src/test/org/apache/lucene/TestDemo.java index 363f826513f..d53f5cc9586 100644 --- a/lucene/src/test/org/apache/lucene/TestDemo.java +++ b/lucene/src/test/org/apache/lucene/TestDemo.java @@ -57,7 +57,7 @@ public class TestDemo extends LuceneTestCase { Document doc = new Document(); String longTerm = "longtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongterm"; String text = "This is the text to be indexed. " + longTerm; - doc.add(new Field("fieldname", text, Field.Store.YES, + doc.add(newField("fieldname", text, Field.Store.YES, Field.Index.ANALYZED)); iwriter.addDocument(doc); iwriter.close(); diff --git a/lucene/src/test/org/apache/lucene/TestExternalCodecs.java b/lucene/src/test/org/apache/lucene/TestExternalCodecs.java index cb5e9bdeda2..ea7962ba7fc 100644 --- a/lucene/src/test/org/apache/lucene/TestExternalCodecs.java +++ b/lucene/src/test/org/apache/lucene/TestExternalCodecs.java @@ -607,11 +607,11 @@ public class TestExternalCodecs extends LuceneTestCase { w.setMergeFactor(3); Document doc = new Document(); // uses default codec: - doc.add(new Field("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", Field.Store.NO, Field.Index.ANALYZED)); // uses pulsing codec: - doc.add(new Field("field2", "this field uses the pulsing codec as the test", Field.Store.NO, Field.Index.ANALYZED)); + doc.add(newField("field2", "this field uses the pulsing codec as the test", Field.Store.NO, Field.Index.ANALYZED)); - Field idField = new Field("id", "", Field.Store.NO, Field.Index.NOT_ANALYZED); + Field idField = newField("id", "", Field.Store.NO, Field.Index.NOT_ANALYZED); doc.add(idField); for(int i=0;i0) { int k = i-1; @@ -1196,7 +1196,7 @@ public class TestIndexReaderReopen extends LuceneTestCase { ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(10); for(int i=0;i<4;i++) { Document doc = new Document(); - doc.add(new Field("id", ""+i, Field.Store.NO, Field.Index.NOT_ANALYZED)); + doc.add(newField("id", ""+i, Field.Store.NO, Field.Index.NOT_ANALYZED)); writer.addDocument(doc); Map data = new HashMap(); data.put("index", i+""); diff --git a/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java b/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java index 290483a5c50..78bb1906026 100644 --- a/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java +++ b/lucene/src/test/org/apache/lucene/index/TestIndexWriter.java @@ -148,18 +148,18 @@ public class TestIndexWriter extends LuceneTestCase { dir.close(); } - private static void addDoc(IndexWriter writer) throws IOException + private void addDoc(IndexWriter writer) throws IOException { Document doc = new Document(); - doc.add(new Field("content", "aaa", Field.Store.NO, Field.Index.ANALYZED)); + doc.add(newField("content", "aaa", Field.Store.NO, Field.Index.ANALYZED)); writer.addDocument(doc); } private void addDocWithIndex(IndexWriter writer, int index) throws IOException { Document doc = new Document(); - doc.add(new Field("content", "aaa " + index, Field.Store.YES, Field.Index.ANALYZED)); - doc.add(new Field("id", "" + index, Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("content", "aaa " + index, Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("id", "" + index, Field.Store.YES, Field.Index.ANALYZED)); writer.addDocument(doc); } @@ -555,7 +555,7 @@ public class TestIndexWriter extends LuceneTestCase { MockDirectoryWrapper dir = newDirectory(); final Document doc = new Document(); - doc.add(new Field("content", "aaa", Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("content", "aaa", Field.Store.YES, Field.Index.ANALYZED)); for(int numDocs=38;numDocs<500;numDocs += 38) { LogDocMergePolicy ldmp = new LogDocMergePolicy(); @@ -596,7 +596,7 @@ public class TestIndexWriter extends LuceneTestCase { MockDirectoryWrapper dir = newDirectory(); final Document doc = new Document(); - doc.add(new Field("content", "aaa", Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("content", "aaa", Field.Store.YES, Field.Index.ANALYZED)); LogDocMergePolicy ldmp = new LogDocMergePolicy(); ldmp.setMinMergeDocs(1); @@ -1137,12 +1137,12 @@ public class TestIndexWriter extends LuceneTestCase { IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(10)); for(int j=0;j<100;j++) { Document doc = new Document(); - doc.add(new Field("a"+j, "aaa" + j, Field.Store.YES, Field.Index.ANALYZED)); - doc.add(new Field("b"+j, "aaa" + j, Field.Store.YES, Field.Index.ANALYZED)); - doc.add(new Field("c"+j, "aaa" + j, Field.Store.YES, Field.Index.ANALYZED)); - doc.add(new Field("d"+j, "aaa", Field.Store.YES, Field.Index.ANALYZED)); - doc.add(new Field("e"+j, "aaa", Field.Store.YES, Field.Index.ANALYZED)); - doc.add(new Field("f"+j, "aaa", Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("a"+j, "aaa" + j, Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("b"+j, "aaa" + j, Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("c"+j, "aaa" + j, Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("d"+j, "aaa", Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("e"+j, "aaa", Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("f"+j, "aaa", Field.Store.YES, Field.Index.ANALYZED)); writer.addDocument(doc); } writer.close(); @@ -1169,7 +1169,7 @@ public class TestIndexWriter extends LuceneTestCase { int lastNumFile = dir.listAll().length; for(int j=0;j<9;j++) { Document doc = new Document(); - doc.add(new Field("field", "aaa" + j, Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("field", "aaa" + j, Field.Store.YES, Field.Index.ANALYZED)); writer.addDocument(doc); int numFile = dir.listAll().length; // Verify that with a tiny RAM buffer we see new @@ -1198,7 +1198,7 @@ public class TestIndexWriter extends LuceneTestCase { int lastFlushCount = -1; for(int j=1;j<52;j++) { Document doc = new Document(); - doc.add(new Field("field", "aaa" + j, Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("field", "aaa" + j, Field.Store.YES, Field.Index.ANALYZED)); writer.addDocument(doc); _TestUtil.syncConcurrentMerges(writer); int flushCount = writer.getFlushCount(); @@ -1255,7 +1255,7 @@ public class TestIndexWriter extends LuceneTestCase { for(int j=1;j<52;j++) { Document doc = new Document(); - doc.add(new Field("field", "aaa" + j, Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("field", "aaa" + j, Field.Store.YES, Field.Index.ANALYZED)); writer.addDocument(doc); } @@ -1315,7 +1315,7 @@ public class TestIndexWriter extends LuceneTestCase { for(int j=0;j<100;j++) { Document doc = new Document(); for(int k=0;k<100;k++) { - doc.add(new Field("field", Integer.toString(random.nextInt()), Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("field", Integer.toString(random.nextInt()), Field.Store.YES, Field.Index.ANALYZED)); } writer.addDocument(doc); } @@ -1324,7 +1324,7 @@ public class TestIndexWriter extends LuceneTestCase { // occurs (heavy on byte blocks) for(int j=0;j<100;j++) { Document doc = new Document(); - doc.add(new Field("field", "aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa", Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("field", "aaa aaa aaa aaa aaa aaa aaa aaa aaa aaa", Field.Store.YES, Field.Index.ANALYZED)); writer.addDocument(doc); } @@ -1339,7 +1339,7 @@ public class TestIndexWriter extends LuceneTestCase { String longTerm = b.toString(); Document doc = new Document(); - doc.add(new Field("field", longTerm, Field.Store.YES, Field.Index.ANALYZED)); + doc.add(newField("field", longTerm, Field.Store.YES, Field.Index.ANALYZED)); writer.addDocument(doc); } } @@ -1359,7 +1359,7 @@ public class TestIndexWriter extends LuceneTestCase { // Enable norms for only 1 doc, pre flush for(int j=0;j<10;j++) { Document doc = new Document(); - Field f = new Field("field", "aaa", Field.Store.YES, Field.Index.ANALYZED); + Field f = newField("field", "aaa", Field.Store.YES, Field.Index.ANALYZED); if (j != 8) { f.setOmitNorms(true); } @@ -1380,7 +1380,7 @@ public class TestIndexWriter extends LuceneTestCase { // Enable norms for only 1 doc, post flush for(int j=0;j<27;j++) { Document doc = new Document(); - Field f = new Field("field", "aaa", Field.Store.YES, Field.Index.ANALYZED); + Field f = newField("field", "aaa", Field.Store.YES, Field.Index.ANALYZED); if (j != 26) { f.setOmitNorms(true); } @@ -1412,7 +1412,7 @@ public class TestIndexWriter extends LuceneTestCase { b.append(" a a a a a a a a"); } Document doc = new Document(); - doc.add(new Field("field", b.toString(), Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); + doc.add(newField("field", b.toString(), Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); writer.addDocument(doc); writer.close(); @@ -1477,7 +1477,7 @@ public class TestIndexWriter extends LuceneTestCase { TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2)); ((LogMergePolicy) writer.getMergePolicy()).setMergeFactor(10); Document doc = new Document(); - doc.add(new Field("field", "aaa", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); + doc.add(newField("field", "aaa", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); for(int i=0;i<19;i++) writer.addDocument(doc); writer.flush(false, true, true); @@ -1496,7 +1496,7 @@ public class TestIndexWriter extends LuceneTestCase { Directory dir = newDirectory(); IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())); Document doc = new Document(); - doc.add(new Field("field", "aaa", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); + doc.add(newField("field", "aaa", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); writer.addDocument(doc); writer.commit(); writer.addDocument(new Document()); @@ -1520,7 +1520,7 @@ public class TestIndexWriter extends LuceneTestCase { .setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(2)); ((LogMergePolicy) writer.getConfig().getMergePolicy()).setMergeFactor(101); Document doc = new Document(); - doc.add(new Field("field", "aaa", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); + doc.add(newField("field", "aaa", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); for(int i=0;i<200;i++) writer.addDocument(doc); writer.optimize(false); @@ -1573,7 +1573,7 @@ public class TestIndexWriter extends LuceneTestCase { TEST_VERSION_CURRENT, new MockAnalyzer())); Document document = new Document(); - document.add(new Field("tvtest", "", Store.NO, Index.ANALYZED, TermVector.YES)); + document.add(newField("tvtest", "", Store.NO, Index.ANALYZED, TermVector.YES)); iw.addDocument(document); iw.close(); dir.close(); @@ -1585,17 +1585,17 @@ public class TestIndexWriter extends LuceneTestCase { IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())); Document document = new Document(); - document.add(new Field("tvtest", "a b c", Field.Store.NO, Field.Index.ANALYZED, + document.add(newField("tvtest", "a b c", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.YES)); iw.addDocument(document); document = new Document(); - document.add(new Field("tvtest", "x y z", Field.Store.NO, Field.Index.ANALYZED, + document.add(newField("tvtest", "x y z", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.NO)); iw.addDocument(document); // Make first segment iw.commit(); - document.add(new Field("tvtest", "a b c", Field.Store.NO, Field.Index.ANALYZED, + document.add(newField("tvtest", "a b c", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.YES)); iw.addDocument(document); // Make 2nd segment @@ -1612,13 +1612,13 @@ public class TestIndexWriter extends LuceneTestCase { IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())); Document document = new Document(); - document.add(new Field("tvtest", "a b c", Field.Store.NO, Field.Index.ANALYZED, + document.add(newField("tvtest", "a b c", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.YES)); iw.addDocument(document); iw.commit(); document = new Document(); - document.add(new Field("tvtest", "x y z", Field.Store.NO, Field.Index.ANALYZED, + document.add(newField("tvtest", "x y z", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.NO)); iw.addDocument(document); // Make first segment @@ -1626,7 +1626,7 @@ public class TestIndexWriter extends LuceneTestCase { iw.optimize(); - document.add(new Field("tvtest", "a b c", Field.Store.NO, Field.Index.ANALYZED, + document.add(newField("tvtest", "a b c", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.YES)); iw.addDocument(document); // Make 2nd segment @@ -1648,7 +1648,7 @@ public class TestIndexWriter extends LuceneTestCase { ((LogMergePolicy) conf.getMergePolicy()).setMergeFactor(2); IndexWriter iw = new IndexWriter(dir, conf); Document document = new Document(); - document.add(new Field("tvtest", "a b c", Field.Store.NO, Field.Index.ANALYZED, + document.add(newField("tvtest", "a b c", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.YES)); Thread.currentThread().setPriority(Thread.MAX_PRIORITY); for(int i=0;i<4;i++) @@ -1692,7 +1692,7 @@ public class TestIndexWriter extends LuceneTestCase { lmp.setMergeFactor(2); IndexWriter iw = new IndexWriter(dir, conf); Document document = new Document(); - document.add(new Field("tvtest", "a b c", Field.Store.NO, Field.Index.ANALYZED, + document.add(newField("tvtest", "a b c", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.YES)); for(int i=0;i<177;i++) iw.addDocument(document); @@ -1725,7 +1725,7 @@ public class TestIndexWriter extends LuceneTestCase { Document doc = new Document(); String contents = "aa bb cc dd ee ff gg hh ii jj kk"; - doc.add(new Field("content", contents, Field.Store.NO, + doc.add(newField("content", contents, Field.Store.NO, Field.Index.ANALYZED)); try { writer.addDocument(doc); @@ -1735,13 +1735,13 @@ public class TestIndexWriter extends LuceneTestCase { // Make sure we can add another normal document doc = new Document(); - doc.add(new Field("content", "aa bb cc dd", Field.Store.NO, + doc.add(newField("content", "aa bb cc dd", Field.Store.NO, Field.Index.ANALYZED)); writer.addDocument(doc); // Make sure we can add another normal document doc = new Document(); - doc.add(new Field("content", "aa bb cc dd", Field.Store.NO, + doc.add(newField("content", "aa bb cc dd", Field.Store.NO, Field.Index.ANALYZED)); writer.addDocument(doc); @@ -1813,7 +1813,7 @@ public class TestIndexWriter extends LuceneTestCase { IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2)); Document doc = new Document(); String contents = "aa bb cc dd ee ff gg hh ii jj kk"; - doc.add(new Field("content", contents, Field.Store.NO, + doc.add(newField("content", contents, Field.Store.NO, Field.Index.ANALYZED)); boolean hitError = false; for(int i=0;i<200;i++) { @@ -1869,13 +1869,13 @@ public class TestIndexWriter extends LuceneTestCase { IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, analyzer)); //writer.setInfoStream(System.out); Document doc = new Document(); - doc.add(new Field("contents", "here are some contents", Field.Store.YES, + doc.add(newField("contents", "here are some contents", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); writer.addDocument(doc); writer.addDocument(doc); - doc.add(new Field("crash", "this should crash after 4 terms", Field.Store.YES, + doc.add(newField("crash", "this should crash after 4 terms", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); - doc.add(new Field("other", "this will not get indexed", Field.Store.YES, + doc.add(newField("other", "this will not get indexed", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); try { writer.addDocument(doc); @@ -1885,7 +1885,7 @@ public class TestIndexWriter extends LuceneTestCase { if (0 == i) { doc = new Document(); - doc.add(new Field("contents", "here are some contents", Field.Store.YES, + doc.add(newField("contents", "here are some contents", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); writer.addDocument(doc); writer.addDocument(doc); @@ -1914,7 +1914,7 @@ public class TestIndexWriter extends LuceneTestCase { writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, analyzer).setMaxBufferedDocs(10)); doc = new Document(); - doc.add(new Field("contents", "here are some contents", Field.Store.YES, + doc.add(newField("contents", "here are some contents", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS)); for(int j=0;j<17;j++) writer.addDocument(doc); @@ -1965,13 +1965,13 @@ public class TestIndexWriter extends LuceneTestCase { try { for(int iter=0;iter allTerms = new HashSet(); @@ -4799,7 +4799,7 @@ public class TestIndexWriter extends LuceneTestCase { s.append(' ').append(""+i); } Document d = new Document(); - Field f = new Field("field", s.toString(), Field.Store.NO, Field.Index.ANALYZED); + Field f = newField("field", s.toString(), Field.Store.NO, Field.Index.ANALYZED); d.add(f); w.addDocument(d); IndexReader r = w.getReader(2).getSequentialSubReaders()[0]; @@ -4824,7 +4824,7 @@ public class TestIndexWriter extends LuceneTestCase { IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer())); ((LogMergePolicy) w.getMergePolicy()).setUseCompoundFile(true); Document doc = new Document(); - doc.add(new Field("field", "go", Field.Store.NO, Field.Index.ANALYZED)); + doc.add(newField("field", "go", Field.Store.NO, Field.Index.ANALYZED)); w.addDocument(doc); IndexReader r; if (iter == 0) { @@ -4887,7 +4887,7 @@ public class TestIndexWriter extends LuceneTestCase { // First commit Document doc = new Document(); - doc.add(new Field("c", "val", Store.YES, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS)); + doc.add(newField("c", "val", Store.YES, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS)); writer.addDocument(doc); writer.commit(); assertEquals(1, IndexReader.listCommits(dir).size()); @@ -4897,7 +4897,7 @@ public class TestIndexWriter extends LuceneTestCase { // Second commit - now KeepOnlyLastCommit cannot delete the prev commit. doc = new Document(); - doc.add(new Field("c", "val", Store.YES, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS)); + doc.add(newField("c", "val", Store.YES, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS)); writer.addDocument(doc); writer.commit(); assertEquals(2, IndexReader.listCommits(dir).size()); @@ -4928,7 +4928,7 @@ public class TestIndexWriter extends LuceneTestCase { FlushCountingIndexWriter w = new FlushCountingIndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setRAMBufferSizeMB(0.5).setMaxBufferedDocs(-1).setMaxBufferedDeleteTerms(-1)); //w.setInfoStream(System.out); Document doc = new Document(); - doc.add(new Field("field", "go 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20", Field.Store.NO, Field.Index.ANALYZED)); + doc.add(newField("field", "go 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20", Field.Store.NO, Field.Index.ANALYZED)); int num = 6 * RANDOM_MULTIPLIER; for (int iter = 0; iter < num; iter++) { int count = 0; @@ -5004,13 +5004,13 @@ public class TestIndexWriter extends LuceneTestCase { Document doc = new Document(); // create as many files as possible - doc.add(new Field("c", "val", Store.YES, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS)); + doc.add(newField("c", "val", Store.YES, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS)); writer.addDocument(doc); // Adding just one document does not call flush yet. assertEquals("only the stored and term vector files should exist in the directory", 5 + extraFileCount, dir.listAll().length); doc = new Document(); - doc.add(new Field("c", "val", Store.YES, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS)); + doc.add(newField("c", "val", Store.YES, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS)); writer.addDocument(doc); // The second document should cause a flush. assertTrue("flush should have occurred and files created", dir.listAll().length > 5 + extraFileCount); @@ -5034,7 +5034,7 @@ public class TestIndexWriter extends LuceneTestCase { TEST_VERSION_CURRENT, new MockAnalyzer()).setMaxBufferedDocs(2)); Document doc = new Document(); - doc.add(new Field("c", "val", Store.YES, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS)); + doc.add(newField("c", "val", Store.YES, Index.ANALYZED, TermVector.WITH_POSITIONS_OFFSETS)); w.addDocument(doc); w.addDocument(doc); IndexWriter w2 = new IndexWriter(dir, newIndexWriterConfig( @@ -5140,7 +5140,7 @@ public class TestIndexWriter extends LuceneTestCase { final List fieldIDs = new ArrayList(); - Field idField = new Field("id", "", Field.Store.YES, Field.Index.NOT_ANALYZED); + Field idField = newField("id", "", Field.Store.YES, Field.Index.NOT_ANALYZED); for(int i=0;i fields = new ArrayList(); String idString = getIdString(); - Field idField = new Field(idTerm.field(), idString, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS); + Field idField = newField(idTerm.field(), idString, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS); fields.add(idField); int nFields = nextInt(maxFields); @@ -663,16 +669,16 @@ public class TestStressIndexing2 extends MultiCodecTestCase { switch (nextInt(4)) { case 0: - fields.add(new Field("f" + nextInt(100), getString(1), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS, tvVal)); + fields.add(newField("f" + nextInt(100), getString(1), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS, tvVal)); break; case 1: - fields.add(new Field("f" + nextInt(100), getString(0), Field.Store.NO, Field.Index.ANALYZED, tvVal)); + fields.add(newField("f" + nextInt(100), getString(0), Field.Store.NO, Field.Index.ANALYZED, tvVal)); break; case 2: - fields.add(new Field("f" + nextInt(100), getString(0), Field.Store.YES, Field.Index.NO, Field.TermVector.NO)); + fields.add(newField("f" + nextInt(100), getString(0), Field.Store.YES, Field.Index.NO, Field.TermVector.NO)); break; case 3: - fields.add(new Field("f" + nextInt(100), getString(bigFieldSize), Field.Store.YES, Field.Index.ANALYZED, tvVal)); + fields.add(newField("f" + nextInt(100), getString(bigFieldSize), Field.Store.YES, Field.Index.ANALYZED, tvVal)); break; } } diff --git a/lucene/src/test/org/apache/lucene/index/TestTermdocPerf.java b/lucene/src/test/org/apache/lucene/index/TestTermdocPerf.java index 0f57af9bb41..a2db7aa37da 100644 --- a/lucene/src/test/org/apache/lucene/index/TestTermdocPerf.java +++ b/lucene/src/test/org/apache/lucene/index/TestTermdocPerf.java @@ -69,7 +69,7 @@ public class TestTermdocPerf extends LuceneTestCase { }; Document doc = new Document(); - doc.add(new Field(field,val, Field.Store.NO, Field.Index.NOT_ANALYZED_NO_NORMS)); + doc.add(newField(field,val, Field.Store.NO, Field.Index.NOT_ANALYZED_NO_NORMS)); IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, analyzer) .setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(100)); diff --git a/lucene/src/test/org/apache/lucene/index/TestThreadedOptimize.java b/lucene/src/test/org/apache/lucene/index/TestThreadedOptimize.java index 6f6d3a7aba7..a15266581e7 100644 --- a/lucene/src/test/org/apache/lucene/index/TestThreadedOptimize.java +++ b/lucene/src/test/org/apache/lucene/index/TestThreadedOptimize.java @@ -66,8 +66,8 @@ public class TestThreadedOptimize extends LuceneTestCase { for(int i=0;i<200;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), Field.Store.NO, Field.Index.ANALYZED)); + 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)); writer.addDocument(d); } @@ -87,8 +87,8 @@ public class TestThreadedOptimize extends LuceneTestCase { writerFinal.optimize(false); for(int k=0;k<17*(1+iFinal);k++) { Document d = new Document(); - d.add(new Field("id", iterFinal + "_" + iFinal + "_" + j + "_" + k, Field.Store.YES, Field.Index.NOT_ANALYZED)); - d.add(new Field("contents", English.intToEnglish(iFinal+k), Field.Store.NO, Field.Index.ANALYZED)); + d.add(newField("id", iterFinal + "_" + iFinal + "_" + j + "_" + k, Field.Store.YES, Field.Index.NOT_ANALYZED)); + d.add(newField("contents", English.intToEnglish(iFinal+k), Field.Store.NO, Field.Index.ANALYZED)); writerFinal.addDocument(d); } for(int k=0;k<9*(1+iFinal);k++) diff --git a/lucene/src/test/org/apache/lucene/index/TestTransactionRollback.java b/lucene/src/test/org/apache/lucene/index/TestTransactionRollback.java index da5d406b701..6a24a8aad1d 100644 --- a/lucene/src/test/org/apache/lucene/index/TestTransactionRollback.java +++ b/lucene/src/test/org/apache/lucene/index/TestTransactionRollback.java @@ -130,7 +130,7 @@ public class TestTransactionRollback extends LuceneTestCase { IndexWriter w=new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, new MockAnalyzer()).setIndexDeletionPolicy(sdp)); for(int currentRecordId=1;currentRecordId<=100;currentRecordId++) { Document doc=new Document(); - doc.add(new Field(FIELD_RECORD_ID,""+currentRecordId,Field.Store.YES,Field.Index.ANALYZED)); + doc.add(newField(FIELD_RECORD_ID,""+currentRecordId,Field.Store.YES,Field.Index.ANALYZED)); w.addDocument(doc); if (currentRecordId%10 == 0) { diff --git a/lucene/src/test/org/apache/lucene/index/TestTransactions.java b/lucene/src/test/org/apache/lucene/index/TestTransactions.java index d2587f6f37e..b14756f7cb7 100644 --- a/lucene/src/test/org/apache/lucene/index/TestTransactions.java +++ b/lucene/src/test/org/apache/lucene/index/TestTransactions.java @@ -140,8 +140,8 @@ public class TestTransactions extends LuceneTestCase { for(int j=0; j<10; j++) { Document d = new Document(); int n = random.nextInt(); - d.add(new Field("id", Integer.toString(nextID++), Field.Store.YES, Field.Index.NOT_ANALYZED)); - d.add(new Field("contents", English.intToEnglish(n), Field.Store.NO, Field.Index.ANALYZED)); + 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)); writer.addDocument(d); } @@ -185,7 +185,7 @@ public class TestTransactions extends LuceneTestCase { for(int j=0; j<7; j++) { Document d = new Document(); int n = random.nextInt(); - d.add(new Field("contents", English.intToEnglish(n), Field.Store.NO, Field.Index.ANALYZED)); + d.add(newField("contents", English.intToEnglish(n), Field.Store.NO, Field.Index.ANALYZED)); writer.addDocument(d); } writer.close(); diff --git a/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestSurrogates.java b/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestSurrogates.java index 7d07a0070a7..46663df8e16 100644 --- a/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestSurrogates.java +++ b/lucene/src/test/org/apache/lucene/index/codecs/preflex/TestSurrogates.java @@ -297,7 +297,7 @@ public class TestSurrogates extends LuceneTestCaseJ4 { uniqueTerms.add(term); fieldTerms.add(new Term(field, term)); Document doc = new Document(); - doc.add(new Field(field, term, Field.Store.NO, Field.Index.NOT_ANALYZED)); + doc.add(newField(field, term, Field.Store.NO, Field.Index.NOT_ANALYZED)); w.addDocument(doc); } uniqueTermCount += uniqueTerms.size(); diff --git a/lucene/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java b/lucene/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java index d71adbf790c..93c7c716a26 100644 --- a/lucene/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java +++ b/lucene/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java @@ -284,7 +284,7 @@ public class TestMultiFieldQueryParser extends LuceneTestCase { Directory ramDir = newDirectory(); IndexWriter iw = new IndexWriter(ramDir, newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer)); Document doc = new Document(); - doc.add(new Field("body", "blah the footest blah", Field.Store.NO, Field.Index.ANALYZED)); + doc.add(newField("body", "blah the footest blah", Field.Store.NO, Field.Index.ANALYZED)); iw.addDocument(doc); iw.close(); diff --git a/lucene/src/test/org/apache/lucene/queryParser/TestQueryParser.java b/lucene/src/test/org/apache/lucene/queryParser/TestQueryParser.java index bb6be7fbd01..a7ef9377514 100644 --- a/lucene/src/test/org/apache/lucene/queryParser/TestQueryParser.java +++ b/lucene/src/test/org/apache/lucene/queryParser/TestQueryParser.java @@ -571,7 +571,7 @@ public class TestQueryParser extends LocalizedTestCase { Directory ramDir = newDirectory(); IndexWriter iw = new IndexWriter(ramDir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(MockTokenizer.WHITESPACE, false))); Document doc = new Document(); - doc.add(new Field("content","\u0633\u0627\u0628", + doc.add(newField("content","\u0633\u0627\u0628", Field.Store.YES, Field.Index.NOT_ANALYZED)); iw.addDocument(doc); iw.close(); @@ -1131,13 +1131,13 @@ public class TestQueryParser extends LocalizedTestCase { assertEquals(expected, hits.length); } - private static void addDateDoc(String content, int year, int month, + private void addDateDoc(String content, int year, int month, int day, int hour, int minute, int second, IndexWriter iw) throws IOException { Document d = new Document(); - d.add(new Field("f", content, Field.Store.YES, Field.Index.ANALYZED)); + d.add(newField("f", content, Field.Store.YES, Field.Index.ANALYZED)); Calendar cal = Calendar.getInstance(Locale.ENGLISH); cal.set(year, month-1, day, hour, minute, second); - d.add(new Field("date", DateField.dateToString(cal.getTime()), Field.Store.YES, Field.Index.NOT_ANALYZED)); + d.add(newField("date", DateField.dateToString(cal.getTime()), Field.Store.YES, Field.Index.NOT_ANALYZED)); iw.addDocument(d); } @@ -1155,7 +1155,7 @@ public class TestQueryParser extends LocalizedTestCase { Analyzer a = new MockAnalyzer(MockTokenizer.SIMPLE, true, MockTokenFilter.ENGLISH_STOPSET, true); IndexWriter w = new IndexWriter(dir, newIndexWriterConfig( TEST_VERSION_CURRENT, a)); Document doc = new Document(); - doc.add(new Field("f", "the wizard of ozzy", Field.Store.NO, Field.Index.ANALYZED)); + doc.add(newField("f", "the wizard of ozzy", Field.Store.NO, Field.Index.ANALYZED)); w.addDocument(doc); IndexReader r = w.getReader(); w.close(); diff --git a/lucene/src/test/org/apache/lucene/search/BaseTestRangeFilter.java b/lucene/src/test/org/apache/lucene/search/BaseTestRangeFilter.java index cffe44c427e..9bb73d9542e 100644 --- a/lucene/src/test/org/apache/lucene/search/BaseTestRangeFilter.java +++ b/lucene/src/test/org/apache/lucene/search/BaseTestRangeFilter.java @@ -111,7 +111,7 @@ public class BaseTestRangeFilter extends LuceneTestCase { for (int d = minId; d <= maxId; d++) { Document doc = new Document(); - doc.add(new Field("id", pad(d), Field.Store.YES, + doc.add(newField("id", pad(d), Field.Store.YES, Field.Index.NOT_ANALYZED)); int r = index.allowNegativeRandomInts ? random.nextInt() : random .nextInt(Integer.MAX_VALUE); @@ -121,9 +121,9 @@ public class BaseTestRangeFilter extends LuceneTestCase { if (r < index.minR) { index.minR = r; } - doc.add(new Field("rand", pad(r), Field.Store.YES, + doc.add(newField("rand", pad(r), Field.Store.YES, Field.Index.NOT_ANALYZED)); - doc.add(new Field("body", "body", Field.Store.YES, + doc.add(newField("body", "body", Field.Store.YES, Field.Index.NOT_ANALYZED)); writer.addDocument(doc); } diff --git a/lucene/src/test/org/apache/lucene/search/TestAutomatonQuery.java b/lucene/src/test/org/apache/lucene/search/TestAutomatonQuery.java index 835e54f69c4..fc2de881a26 100644 --- a/lucene/src/test/org/apache/lucene/search/TestAutomatonQuery.java +++ b/lucene/src/test/org/apache/lucene/search/TestAutomatonQuery.java @@ -43,11 +43,11 @@ public class TestAutomatonQuery extends LuceneTestCase { directory = newDirectory(); RandomIndexWriter writer = new RandomIndexWriter(random, directory); Document doc = new Document(); - Field titleField = new Field("title", "some title", Field.Store.NO, + Field titleField = newField("title", "some title", Field.Store.NO, Field.Index.ANALYZED); - Field field = new Field(FN, "this is document one 2345", Field.Store.NO, + Field field = newField(FN, "this is document one 2345", Field.Store.NO, Field.Index.ANALYZED); - Field footerField = new Field("footer", "a footer", Field.Store.NO, + Field footerField = newField("footer", "a footer", Field.Store.NO, Field.Index.ANALYZED); doc.add(titleField); doc.add(field); diff --git a/lucene/src/test/org/apache/lucene/search/TestAutomatonQueryUnicode.java b/lucene/src/test/org/apache/lucene/search/TestAutomatonQueryUnicode.java index 77f20eef94b..29bec6c066a 100644 --- a/lucene/src/test/org/apache/lucene/search/TestAutomatonQueryUnicode.java +++ b/lucene/src/test/org/apache/lucene/search/TestAutomatonQueryUnicode.java @@ -46,11 +46,11 @@ public class TestAutomatonQueryUnicode extends LuceneTestCase { directory = newDirectory(); RandomIndexWriter writer = new RandomIndexWriter(random, directory); Document doc = new Document(); - Field titleField = new Field("title", "some title", Field.Store.NO, + Field titleField = newField("title", "some title", Field.Store.NO, Field.Index.ANALYZED); - Field field = new Field(FN, "", Field.Store.NO, + Field field = newField(FN, "", Field.Store.NO, Field.Index.ANALYZED); - Field footerField = new Field("footer", "a footer", Field.Store.NO, + Field footerField = newField("footer", "a footer", Field.Store.NO, Field.Index.ANALYZED); doc.add(titleField); doc.add(field); diff --git a/lucene/src/test/org/apache/lucene/search/TestBoolean2.java b/lucene/src/test/org/apache/lucene/search/TestBoolean2.java index b9d7114b64a..d95af570ffe 100644 --- a/lucene/src/test/org/apache/lucene/search/TestBoolean2.java +++ b/lucene/src/test/org/apache/lucene/search/TestBoolean2.java @@ -54,7 +54,7 @@ public class TestBoolean2 extends LuceneTestCase { RandomIndexWriter writer= new RandomIndexWriter(random, directory); for (int i = 0; i < docFields.length; i++) { Document doc = new Document(); - doc.add(new Field(field, docFields[i], Field.Store.NO, Field.Index.ANALYZED)); + doc.add(newField(field, docFields[i], Field.Store.NO, Field.Index.ANALYZED)); writer.addDocument(doc); } writer.close(); @@ -77,12 +77,12 @@ public class TestBoolean2 extends LuceneTestCase { RandomIndexWriter w = new RandomIndexWriter(random, dir2); Document doc = new Document(); - doc.add(new Field("field2", "xxx", Field.Store.NO, Field.Index.ANALYZED)); + doc.add(newField("field2", "xxx", Field.Store.NO, Field.Index.ANALYZED)); for(int i=0;i> docs = new ArrayList>(); Document d = new Document(); - Field f = new Field("f", "", Field.Store.NO, Field.Index.ANALYZED); + Field f = newField("f", "", Field.Store.NO, Field.Index.ANALYZED); d.add(f); Random r = random; diff --git a/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java b/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java index d14d440fbc9..03deb2ab8cb 100644 --- a/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java +++ b/lucene/src/test/org/apache/lucene/search/TestPositionIncrement.java @@ -93,7 +93,7 @@ public class TestPositionIncrement extends LuceneTestCase { Directory store = newDirectory(); RandomIndexWriter writer = new RandomIndexWriter(random, store, analyzer); Document d = new Document(); - d.add(new Field("field", "bogus", Field.Store.YES, Field.Index.ANALYZED)); + d.add(newField("field", "bogus", Field.Store.YES, Field.Index.ANALYZED)); writer.addDocument(d); IndexReader reader = writer.getReader(); writer.close(); diff --git a/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java b/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java index c79d332feb6..e1fffc98e22 100644 --- a/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java +++ b/lucene/src/test/org/apache/lucene/search/TestPrefixFilter.java @@ -40,7 +40,7 @@ public class TestPrefixFilter extends LuceneTestCase { RandomIndexWriter writer = new RandomIndexWriter(random, directory); for (int i = 0; i < categories.length; i++) { Document doc = new Document(); - doc.add(new Field("category", categories[i], Field.Store.YES, Field.Index.NOT_ANALYZED)); + doc.add(newField("category", categories[i], Field.Store.YES, Field.Index.NOT_ANALYZED)); writer.addDocument(doc); } IndexReader reader = writer.getReader(); diff --git a/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java b/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java index f5532190d6a..7042b740211 100644 --- a/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java +++ b/lucene/src/test/org/apache/lucene/search/TestPrefixInBooleanQuery.java @@ -50,26 +50,26 @@ public class TestPrefixInBooleanQuery extends LuceneTestCase { for (int i = 0; i < 5137; ++i) { Document doc = new Document(); - doc.add(new Field(FIELD, "meaninglessnames", Field.Store.YES, + doc.add(newField(FIELD, "meaninglessnames", Field.Store.YES, Field.Index.NOT_ANALYZED)); writer.addDocument(doc); } { Document doc = new Document(); - doc.add(new Field(FIELD, "tangfulin", Field.Store.YES, + doc.add(newField(FIELD, "tangfulin", Field.Store.YES, Field.Index.NOT_ANALYZED)); writer.addDocument(doc); } for (int i = 5138; i < 11377; ++i) { Document doc = new Document(); - doc.add(new Field(FIELD, "meaninglessnames", Field.Store.YES, + doc.add(newField(FIELD, "meaninglessnames", Field.Store.YES, Field.Index.NOT_ANALYZED)); writer.addDocument(doc); } { Document doc = new Document(); - doc.add(new Field(FIELD, "tangfulin", Field.Store.YES, + doc.add(newField(FIELD, "tangfulin", Field.Store.YES, Field.Index.NOT_ANALYZED)); writer.addDocument(doc); } diff --git a/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java b/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java index 9ce2893e809..6ff1eb77d4b 100644 --- a/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java +++ b/lucene/src/test/org/apache/lucene/search/TestPrefixQuery.java @@ -39,7 +39,7 @@ public class TestPrefixQuery extends LuceneTestCase { RandomIndexWriter writer = new RandomIndexWriter(random, directory); for (int i = 0; i < categories.length; i++) { Document doc = new Document(); - doc.add(new Field("category", categories[i], Field.Store.YES, Field.Index.NOT_ANALYZED)); + doc.add(newField("category", categories[i], Field.Store.YES, Field.Index.NOT_ANALYZED)); writer.addDocument(doc); } IndexReader reader = writer.getReader(); diff --git a/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java b/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java index 05dca284508..f6cbde967bc 100644 --- a/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java +++ b/lucene/src/test/org/apache/lucene/search/TestPrefixRandom.java @@ -48,7 +48,7 @@ public class TestPrefixRandom extends LuceneTestCase { RandomIndexWriter writer = new RandomIndexWriter(random, dir, new MockAnalyzer(MockTokenizer.KEYWORD, false)); Document doc = new Document(); - Field field = new Field("field", "", Field.Store.NO, Field.Index.NOT_ANALYZED); + Field field = newField("field", "", Field.Store.NO, Field.Index.NOT_ANALYZED); doc.add(field); int num = 2000 * RANDOM_MULTIPLIER; diff --git a/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java b/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java index afe2c733d84..7cc09d18222 100644 --- a/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java +++ b/lucene/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java @@ -34,7 +34,7 @@ public class TestQueryWrapperFilter extends LuceneTestCase { Directory dir = newDirectory(); RandomIndexWriter writer = new RandomIndexWriter(random, dir); Document doc = new Document(); - doc.add(new Field("field", "value", Store.NO, Index.ANALYZED)); + doc.add(newField("field", "value", Store.NO, Index.ANALYZED)); writer.addDocument(doc); IndexReader reader = writer.getReader(); writer.close(); diff --git a/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java b/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java index 6db0cd888ce..843c4d63102 100644 --- a/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java +++ b/lucene/src/test/org/apache/lucene/search/TestRegexpQuery.java @@ -47,7 +47,7 @@ public class TestRegexpQuery extends LuceneTestCase { directory = newDirectory(); RandomIndexWriter writer = new RandomIndexWriter(random, directory); Document doc = new Document(); - doc.add(new Field(FN, + doc.add(newField(FN, "the quick brown fox jumps over the lazy ??? dog 493432 49344", Field.Store.NO, Field.Index.ANALYZED)); writer.addDocument(doc); diff --git a/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java b/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java index a4592814a13..be0fa941fe2 100644 --- a/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java +++ b/lucene/src/test/org/apache/lucene/search/TestRegexpRandom.java @@ -47,7 +47,7 @@ public class TestRegexpRandom extends LuceneTestCase { RandomIndexWriter writer = new RandomIndexWriter(random, dir); Document doc = new Document(); - Field field = new Field("field", "", Field.Store.NO, Field.Index.ANALYZED); + Field field = newField("field", "", Field.Store.NO, Field.Index.ANALYZED); doc.add(field); NumberFormat df = new DecimalFormat("0000", new DecimalFormatSymbols(Locale.ENGLISH)); diff --git a/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java b/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java index 82d1e010463..dce3625bb9d 100644 --- a/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java +++ b/lucene/src/test/org/apache/lucene/search/TestRegexpRandom2.java @@ -56,7 +56,7 @@ public class TestRegexpRandom2 extends LuceneTestCase { RandomIndexWriter writer = new RandomIndexWriter(random, dir, new MockAnalyzer(MockTokenizer.KEYWORD, false)); Document doc = new Document(); - Field field = new Field("field", "", Field.Store.NO, Field.Index.NOT_ANALYZED); + Field field = newField("field", "", Field.Store.NO, Field.Index.NOT_ANALYZED); doc.add(field); List terms = new ArrayList(); int num = 2000 * RANDOM_MULTIPLIER; diff --git a/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java b/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java index 9662765593e..7aba01f55ee 100755 --- a/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java +++ b/lucene/src/test/org/apache/lucene/search/TestScorerPerf.java @@ -64,7 +64,7 @@ public class TestScorerPerf extends LuceneTestCase { Document d = new Document(); for (int j=0; j