From e49eb20a3200f11c70cc585d0c2c465c63c2e0d5 Mon Sep 17 00:00:00 2001 From: Daniel Naber Date: Mon, 6 Sep 2004 22:01:49 +0000 Subject: [PATCH] don't call the deprecated Field API git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150492 13f79535-47bb-0310-9956-ffa450edef68 --- .../lucene/search/TestBooleanPrefixQuery.java | 2 +- .../apache/lucene/search/TestDocBoost.java | 4 ++-- .../lucene/search/TestFilteredQuery.java | 16 +++++++-------- .../apache/lucene/search/TestFuzzyQuery.java | 2 +- .../lucene/search/TestMultiSearcher.java | 20 ++++++++++--------- 5 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/test/org/apache/lucene/search/TestBooleanPrefixQuery.java b/src/test/org/apache/lucene/search/TestBooleanPrefixQuery.java index 0f242bca70c..deeedea7d92 100644 --- a/src/test/org/apache/lucene/search/TestBooleanPrefixQuery.java +++ b/src/test/org/apache/lucene/search/TestBooleanPrefixQuery.java @@ -67,7 +67,7 @@ public class TestBooleanPrefixQuery extends TestCase { WhitespaceAnalyzer(), true); for (int i = 0; i < categories.length; i++) { Document doc = new Document(); - doc.add(Field.Keyword("category", categories[i])); + doc.add(new Field("category", categories[i], Field.Store.YES, Field.Index.UN_TOKENIZED)); writer.addDocument(doc); } writer.close(); diff --git a/src/test/org/apache/lucene/search/TestDocBoost.java b/src/test/org/apache/lucene/search/TestDocBoost.java index a3bb31541d6..a0b9ec63093 100644 --- a/src/test/org/apache/lucene/search/TestDocBoost.java +++ b/src/test/org/apache/lucene/search/TestDocBoost.java @@ -40,8 +40,8 @@ public class TestDocBoost extends TestCase { RAMDirectory store = new RAMDirectory(); IndexWriter writer = new IndexWriter(store, new SimpleAnalyzer(), true); - Field f1 = Field.Text("field", "word"); - Field f2 = Field.Text("field", "word"); + Field f1 = new Field("field", "word", Field.Store.YES, Field.Index.TOKENIZED); + Field f2 = new Field("field", "word", Field.Store.YES, Field.Index.TOKENIZED); f2.setBoost(2.0f); Document d1 = new Document(); diff --git a/src/test/org/apache/lucene/search/TestFilteredQuery.java b/src/test/org/apache/lucene/search/TestFilteredQuery.java index 5864c88e688..675da47f2c7 100644 --- a/src/test/org/apache/lucene/search/TestFilteredQuery.java +++ b/src/test/org/apache/lucene/search/TestFilteredQuery.java @@ -51,23 +51,23 @@ extends TestCase { IndexWriter writer = new IndexWriter (directory, new WhitespaceAnalyzer(), true); Document doc = new Document(); - doc.add (Field.Text ("field", "one two three four five")); - doc.add (Field.Text ("sorter", "b")); + doc.add (new Field("field", "one two three four five", Field.Store.YES, Field.Index.TOKENIZED)); + doc.add (new Field("sorter", "b", Field.Store.YES, Field.Index.TOKENIZED)); writer.addDocument (doc); doc = new Document(); - doc.add (Field.Text ("field", "one two three four")); - doc.add (Field.Text ("sorter", "d")); + doc.add (new Field("field", "one two three four", Field.Store.YES, Field.Index.TOKENIZED)); + doc.add (new Field("sorter", "d", Field.Store.YES, Field.Index.TOKENIZED)); writer.addDocument (doc); doc = new Document(); - doc.add (Field.Text ("field", "one two three y")); - doc.add (Field.Text ("sorter", "a")); + doc.add (new Field("field", "one two three y", Field.Store.YES, Field.Index.TOKENIZED)); + doc.add (new Field("sorter", "a", Field.Store.YES, Field.Index.TOKENIZED)); writer.addDocument (doc); doc = new Document(); - doc.add (Field.Text ("field", "one two x")); - doc.add (Field.Text ("sorter", "c")); + doc.add (new Field("field", "one two x", Field.Store.YES, Field.Index.TOKENIZED)); + doc.add (new Field("sorter", "c", Field.Store.YES, Field.Index.TOKENIZED)); writer.addDocument (doc); writer.optimize (); diff --git a/src/test/org/apache/lucene/search/TestFuzzyQuery.java b/src/test/org/apache/lucene/search/TestFuzzyQuery.java index 4de01c2dc46..cbb9cd69571 100644 --- a/src/test/org/apache/lucene/search/TestFuzzyQuery.java +++ b/src/test/org/apache/lucene/search/TestFuzzyQuery.java @@ -148,7 +148,7 @@ public class TestFuzzyQuery extends TestCase { private void addDoc(String text, IndexWriter writer) throws IOException { Document doc = new Document(); - doc.add(Field.Text("field", text)); + doc.add(new Field("field", text, Field.Store.YES, Field.Index.TOKENIZED)); writer.addDocument(doc); } diff --git a/src/test/org/apache/lucene/search/TestMultiSearcher.java b/src/test/org/apache/lucene/search/TestMultiSearcher.java index f7e7c83f497..490fa8989f2 100644 --- a/src/test/org/apache/lucene/search/TestMultiSearcher.java +++ b/src/test/org/apache/lucene/search/TestMultiSearcher.java @@ -60,21 +60,23 @@ public class TestMultiSearcher extends TestCase // creating a document to store Document lDoc = new Document(); - lDoc.add(Field.Text("fulltext", "Once upon a time.....")); - lDoc.add(Field.Keyword("id", "doc1")); - lDoc.add(Field.Keyword("handle", "1")); + lDoc.add(new Field("fulltext", "Once upon a time.....", Field.Store.YES, Field.Index.TOKENIZED)); + lDoc.add(new Field("id", "doc1", Field.Store.YES, Field.Index.UN_TOKENIZED)); + lDoc.add(new Field("handle", "1", Field.Store.YES, Field.Index.UN_TOKENIZED)); // creating a document to store Document lDoc2 = new Document(); - lDoc2.add(Field.Text("fulltext", "in a galaxy far far away.....")); - lDoc2.add(Field.Keyword("id", "doc2")); - lDoc2.add(Field.Keyword("handle", "1")); + lDoc2.add(new Field("fulltext", "in a galaxy far far away.....", + Field.Store.YES, Field.Index.TOKENIZED)); + lDoc2.add(new Field("id", "doc2", Field.Store.YES, Field.Index.UN_TOKENIZED)); + lDoc2.add(new Field("handle", "1", Field.Store.YES, Field.Index.UN_TOKENIZED)); // creating a document to store Document lDoc3 = new Document(); - lDoc3.add(Field.Text("fulltext", "a bizarre bug manifested itself....")); - lDoc3.add(Field.Keyword("id", "doc3")); - lDoc3.add(Field.Keyword("handle", "1")); + lDoc3.add(new Field("fulltext", "a bizarre bug manifested itself....", + Field.Store.YES, Field.Index.TOKENIZED)); + lDoc3.add(new Field("id", "doc3", Field.Store.YES, Field.Index.UN_TOKENIZED)); + lDoc3.add(new Field("handle", "1", Field.Store.YES, Field.Index.UN_TOKENIZED)); // creating an index writer for the first index IndexWriter writerA = new IndexWriter(indexStoreA, new StandardAnalyzer(), true);