Apache Lucene open-source search software
update TestDemo code (match overview.html, they were out of whack, plus use non deprecated code)
Mark Robert Millercaa67be37560
diff --git a/src/java/overview.html b/src/java/overview.htmlindex 90144b5f07f..88e342c7a3c 100644--- a/src/java/overview.html+++ b/src/java/overview.html@@ -27,7 +27,7 @@ to check if the results are what we expect):</p><!-- code comes from org.apache.lucene.TestDemo: --><!-- ======================================================== --><!-- = Java Sourcecode to HTML automatically converted code = -->-<!-- = Java2Html Converter 5.0 [2006-02-26] by Markus Gebhard [email protected] = -->+<!-- = Java2Html Converter 5.0 [2006-03-04] by Markus Gebhard [email protected] = --><!-- = Further information: http://www.java2html.de = --><div align="left" class="java"><table border="0" cellpadding="3" cellspacing="0" bgcolor="#ffffff">@@ -35,7 +35,7 @@ to check if the results are what we expect):</p><!-- start source code --><td nowrap="nowrap" valign="top" align="left"><code>-<font color="#ffffff"> </font><font color="#000000">Analyzer analyzer = </font><font color="#7f0055"><b>new </b></font><font color="#000000">StandardAnalyzer</font><font color="#000000">()</font><font color="#000000">;</font><br />+<font color="#ffffff"> </font><font color="#000000">Analyzer analyzer = </font><font color="#7f0055"><b>new </b></font><font color="#000000">StandardAnalyzer</font><font color="#000000">(</font><font color="#000000">Version.LUCENE_CURRENT</font><font color="#000000">)</font><font color="#000000">;</font><br /><font color="#ffffff"></font><br /><font color="#ffffff"> </font><font color="#3f7f5f">// Store the index in memory:</font><br /><font color="#ffffff"> </font><font color="#000000">Directory directory = </font><font color="#7f0055"><b>new </b></font><font color="#000000">RAMDirectory</font><font color="#000000">()</font><font color="#000000">;</font><br />@@ -51,7 +51,7 @@ to check if the results are what we expect):</p><font color="#ffffff"> </font><font color="#000000">iwriter.close</font><font color="#000000">()</font><font color="#000000">;</font><br /><font color="#ffffff"> </font><br /><font color="#ffffff"> </font><font color="#3f7f5f">// Now search the index:</font><br />-<font color="#ffffff"> </font><font color="#000000">IndexSearcher isearcher = </font><font color="#7f0055"><b>new </b></font><font color="#000000">IndexSearcher</font><font color="#000000">(</font><font color="#000000">directory</font><font color="#000000">)</font><font color="#000000">;</font><br />+<font color="#ffffff"> </font><font color="#000000">IndexSearcher isearcher = </font><font color="#7f0055"><b>new </b></font><font color="#000000">IndexSearcher</font><font color="#000000">(</font><font color="#000000">directory, </font><font color="#7f0055"><b>true</b></font><font color="#000000">)</font><font color="#000000">; </font><font color="#3f7f5f">// read-only=true</font><br /><font color="#ffffff"> </font><font color="#3f7f5f">// Parse a simple query that searches for "text":</font><br /><font color="#ffffff"> </font><font color="#000000">QueryParser parser = </font><font color="#7f0055"><b>new </b></font><font color="#000000">QueryParser</font><font color="#000000">(</font><font color="#2a00ff">"fieldname"</font><font color="#000000">, analyzer</font><font color="#000000">)</font><font color="#000000">;</font><br /><font color="#ffffff"> </font><font color="#000000">Query query = parser.parse</font><font color="#000000">(</font><font color="#2a00ff">"text"</font><font color="#000000">)</font><font color="#000000">;</font><br />@@ -68,12 +68,14 @@ to check if the results are what we expect):</p></td><!-- end source code --></tr>+</table></div><!-- = END of automatically generated HTML code = --><!-- ======================================================== -->+<p>The Lucene API is divided into several packages:</p><ul>diff --git a/src/test/org/apache/lucene/TestDemo.java b/src/test/org/apache/lucene/TestDemo.javaindex 6609e7347eb..8a75ab7cc4b 100644--- a/src/test/org/apache/lucene/TestDemo.java+++ b/src/test/org/apache/lucene/TestDemo.java@@ -32,6 +32,7 @@ import org.apache.lucene.search.ScoreDoc;import org.apache.lucene.store.Directory;import org.apache.lucene.store.RAMDirectory;import org.apache.lucene.util.LuceneTestCase;+import org.apache.lucene.util.Version;import org.apache.lucene.util._TestUtil;/**@@ -44,12 +45,12 @@ public class TestDemo extends LuceneTestCase {public void testDemo() throws IOException, ParseException {- Analyzer analyzer = new StandardAnalyzer();+ Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT);// Store the index in memory:Directory directory = new RAMDirectory();// To store an index on disk, use this instead:- //Directory directory = FSDirectory.open(new File("/tmp/testindex"));+ //Directory directory = FSDirectory.open("/tmp/testindex");IndexWriter iwriter = new IndexWriter(directory, analyzer, true,new IndexWriter.MaxFieldLength(25000));Document doc = new Document();@@ -58,11 +59,9 @@ public class TestDemo extends LuceneTestCase {Field.Index.ANALYZED));iwriter.addDocument(doc);iwriter.close();-- _TestUtil.checkIndex(directory);// Now search the index:- IndexSearcher isearcher = new IndexSearcher(directory);+ IndexSearcher isearcher = new IndexSearcher(directory, true); // read-only=true// Parse a simple query that searches for "text":QueryParser parser = new QueryParser("fieldname", analyzer);Query query = parser.parse("text");