lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dna...@apache.org
Subject svn commit: r703881 - /lucene/java/trunk/src/java/overview.html
Date Sun, 12 Oct 2008 21:24:56 GMT
Author: dnaber
Date: Sun Oct 12 14:24:56 2008
New Revision: 703881

URL: http://svn.apache.org/viewvc?rev=703881&view=rev
Log:
update example so no deprecated code is used

Modified:
    lucene/java/trunk/src/java/overview.html

Modified: lucene/java/trunk/src/java/overview.html
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/overview.html?rev=703881&r1=703880&r2=703881&view=diff
==============================================================================
--- lucene/java/trunk/src/java/overview.html (original)
+++ lucene/java/trunk/src/java/overview.html Sun Oct 12 14:24:56 2008
@@ -24,6 +24,7 @@
 Here's a simple example how to use Lucene for indexing and searching (using JUnit
 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  markus@jave.de   = -->
@@ -40,14 +41,13 @@
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">Directory&nbsp;directory&nbsp;=&nbsp;</font><font
color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">RAMDirectory</font><font
color="#000000">()</font><font color="#000000">;</font><br />
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#3f7f5f">//&nbsp;To&nbsp;store&nbsp;an&nbsp;index&nbsp;on&nbsp;disk,&nbsp;use&nbsp;this&nbsp;instead:</font><br
/>
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#3f7f5f">//Directory&nbsp;directory&nbsp;=&nbsp;FSDirectory.getDirectory(&#34;/tmp/testindex&#34;);</font><br
/>
-<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">IndexWriter&nbsp;iwriter&nbsp;=&nbsp;</font><font
color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">IndexWriter</font><font
color="#000000">(</font><font color="#000000">directory,&nbsp;analyzer,&nbsp;</font><font
color="#7f0055"><b>true</b></font><font color="#000000">)</font><font
color="#000000">;</font><br />
-<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">iwriter.setMaxFieldLength</font><font color="#000000">(</font><font
color="#990000">25000</font><font color="#000000">)</font><font color="#000000">;</font><br
/>
+<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">IndexWriter&nbsp;iwriter&nbsp;=&nbsp;</font><font
color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">IndexWriter</font><font
color="#000000">(</font><font color="#000000">directory,&nbsp;analyzer,&nbsp;true,</font><br
/>
+<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">IndexWriter.MaxFieldLength</font><font
color="#000000">(</font><font color="#990000">25000</font><font color="#000000">))</font><font
color="#000000">;</font><br />
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">Document&nbsp;doc&nbsp;=&nbsp;</font><font color="#7f0055"><b>new&nbsp;</b></font><font
color="#000000">Document</font><font color="#000000">()</font><font
color="#000000">;</font><br />
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">String&nbsp;text&nbsp;=&nbsp;</font><font color="#2a00ff">&#34;This&nbsp;is&nbsp;the&nbsp;text&nbsp;to&nbsp;be&nbsp;indexed.&#34;</font><font
color="#000000">;</font><br />
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">doc.add</font><font color="#000000">(</font><font
color="#7f0055"><b>new&nbsp;</b></font><font color="#000000">Field</font><font
color="#000000">(</font><font color="#2a00ff">&#34;fieldname&#34;</font><font
color="#000000">,&nbsp;text,&nbsp;Field.Store.YES,</font><br />
-<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">Field.Index.TOKENIZED</font><font color="#000000">))</font><font
color="#000000">;</font><br />
+<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">Field.Index.ANALYZED</font><font color="#000000">))</font><font
color="#000000">;</font><br />
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">iwriter.addDocument</font><font color="#000000">(</font><font
color="#000000">doc</font><font color="#000000">)</font><font color="#000000">;</font><br
/>
-<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">iwriter.optimize</font><font color="#000000">()</font><font
color="#000000">;</font><br />
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">iwriter.close</font><font color="#000000">()</font><font
color="#000000">;</font><br />
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><br />
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#3f7f5f">//&nbsp;Now&nbsp;search&nbsp;the&nbsp;index:</font><br
/>
@@ -55,11 +55,11 @@
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#3f7f5f">//&nbsp;Parse&nbsp;a&nbsp;simple&nbsp;query&nbsp;that&nbsp;searches&nbsp;for&nbsp;&#34;text&#34;:</font><br
/>
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">QueryParser&nbsp;parser&nbsp;=&nbsp;</font><font color="#7f0055"><b>new&nbsp;</b></font><font
color="#000000">QueryParser</font><font color="#000000">(</font><font
color="#2a00ff">&#34;fieldname&#34;</font><font color="#000000">,&nbsp;analyzer</font><font
color="#000000">)</font><font color="#000000">;</font><br />
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">Query&nbsp;query&nbsp;=&nbsp;parser.parse</font><font
color="#000000">(</font><font color="#2a00ff">&#34;text&#34;</font><font
color="#000000">)</font><font color="#000000">;</font><br />
-<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">Hits&nbsp;hits&nbsp;=&nbsp;isearcher.search</font><font
color="#000000">(</font><font color="#000000">query</font><font color="#000000">)</font><font
color="#000000">;</font><br />
-<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">assertEquals</font><font color="#000000">(</font><font
color="#990000">1</font><font color="#000000">,&nbsp;hits.length</font><font
color="#000000">())</font><font color="#000000">;</font><br />
+<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">ScoreDoc</font><font color="#000000">[]&nbsp;</font><font
color="#000000">hits&nbsp;=&nbsp;isearcher.search</font><font color="#000000">(</font><font
color="#000000">query,&nbsp;null,&nbsp;</font><font color="#990000">1000</font><font
color="#000000">)</font><font color="#000000">.scoreDocs;</font><br
/>
+<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">assertEquals</font><font color="#000000">(</font><font
color="#990000">1</font><font color="#000000">,&nbsp;hits.length</font><font
color="#000000">)</font><font color="#000000">;</font><br />
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#3f7f5f">//&nbsp;Iterate&nbsp;through&nbsp;the&nbsp;results:</font><br
/>
-<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#7f0055"><b>for&nbsp;</b></font><font color="#000000">(</font><font
color="#7f0055"><b>int&nbsp;</b></font><font color="#000000">i&nbsp;=&nbsp;</font><font
color="#990000">0</font><font color="#000000">;&nbsp;i&nbsp;&lt;&nbsp;hits.length</font><font
color="#000000">()</font><font color="#000000">;&nbsp;i++</font><font
color="#000000">)&nbsp;{</font><br />
-<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">Document&nbsp;hitDoc&nbsp;=&nbsp;hits.doc</font><font
color="#000000">(</font><font color="#000000">i</font><font color="#000000">)</font><font
color="#000000">;</font><br />
+<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#7f0055"><b>for&nbsp;</b></font><font color="#000000">(</font><font
color="#7f0055"><b>int&nbsp;</b></font><font color="#000000">i&nbsp;=&nbsp;</font><font
color="#990000">0</font><font color="#000000">;&nbsp;i&nbsp;&lt;&nbsp;hits.length;&nbsp;i++</font><font
color="#000000">)&nbsp;{</font><br />
+<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">Document&nbsp;hitDoc&nbsp;=&nbsp;isearcher.doc</font><font
color="#000000">(</font><font color="#000000">hits</font><font color="#000000">[</font><font
color="#000000">i</font><font color="#000000">]</font><font color="#000000">.doc</font><font
color="#000000">)</font><font color="#000000">;</font><br />
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">assertEquals</font><font color="#000000">(</font><font
color="#2a00ff">&#34;This&nbsp;is&nbsp;the&nbsp;text&nbsp;to&nbsp;be&nbsp;indexed.&#34;</font><font
color="#000000">,&nbsp;hitDoc.get</font><font color="#000000">(</font><font
color="#2a00ff">&#34;fieldname&#34;</font><font color="#000000">))</font><font
color="#000000">;</font><br />
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">}</font><br />
 <font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font><font
color="#000000">isearcher.close</font><font color="#000000">()</font><font
color="#000000">;</font><br />



Mime
View raw message