lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Otis Gospodnetic <otis_gospodne...@yahoo.com>
Subject Re: Indexing txt-files
Date Thu, 30 Oct 2003 11:35:24 GMT
This is from Lucene demo, included in Lucene distribution.
Look at FileDocument class:

    // Add the contents of the file a field named "contents".  Use a
Text
    // field, specifying a Reader, so that the text of the file is
tokenized.
    // ?? why doesn't FileReader work here ??
    FileInputStream is = new FileInputStream(f);
    Reader reader = new BufferedReader(new InputStreamReader(is));
    doc.add(Field.Text("contents", reader));

Otis


--- GŁnter_Kukies <guenter.kukies@heuft.com> wrote:
>  Hello,
> 
> I  want to add a Text field to a LUCENE Document. I checked the index
> with LUKE, but I don't get any results for search in the contents
> Field. The test.txt is a simple ASCII-File. SimpleAnalyzer is used on
> both sides search and index.
> 
> Here are the relevant code snippets:
> 
> 
> File file = new File("/documents/test.txt");
> 
> addContent(document, new FileInputStream( file ));
> 
> 
>  private static void addContent(Document document, InputStream is)
> throws IOException {
>         try {
>             InputStreamReader input = new InputStreamReader(is);
>             document.add(Field.Text("contents", input ));
>          }
>         catch(Exception ex) {
>             ex.printStackTrace();
>         }
>         finally {
>             if( is != null ) {
>                 is.close();
>             }
>         }
>     }
> 
> 
> Thanks for your help
> 
> GŁnter


__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message