You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by dn...@apache.org on 2004/09/02 23:23:14 UTC

cvs commit: jakarta-lucene/src/demo/org/apache/lucene/demo FileDocument.java

dnaber      2004/09/02 14:23:14

  Modified:    src/demo/org/apache/lucene/demo FileDocument.java
  Log:
  start using the non-deprecated API
  
  Revision  Changes    Path
  1.5       +11 -12    jakarta-lucene/src/demo/org/apache/lucene/demo/FileDocument.java
  
  Index: FileDocument.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/demo/org/apache/lucene/demo/FileDocument.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FileDocument.java	3 Aug 2004 21:53:10 -0000	1.4
  +++ FileDocument.java	2 Sep 2004 21:23:14 -0000	1.5
  @@ -47,23 +47,22 @@
       // make a new, empty document
       Document doc = new Document();
   
  -    // Add the path of the file as a field named "path".  Use a
  -    // Keyword field, so that it's searchable, but so that no attempt is made
  -    // to tokenize the field into words.
  -    doc.add(Field.Keyword("path", f.getPath()));
  +    // Add the path of the file as a field named "path".  Use a field that is 
  +    // indexed (i.e. searchable), but don't tokenize the field into words.
  +    doc.add(new Field("path", f.getPath(), Field.Store.YES, Field.Index.UN_TOKENIZED));
   
  -    // Add the last modified date of the file a field named "modified".  Use a
  -    // Keyword field, so that it's searchable, but so that no attempt is made
  -    // to tokenize the field into words.
  -    doc.add(Field.Keyword("modified",
  -			  DateField.timeToString(f.lastModified())));
  +    // Add the last modified date of the file a field named "modified".  Use 
  +    // a field that is indexed (i.e. searchable), but don't tokenize the field
  +    // into words.
  +    doc.add(new Field("modified", DateField.timeToString(f.lastModified()),
  +        Field.Store.YES, Field.Index.UN_TOKENIZED));
   
  -    // 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.
  +    // Add the contents of the file to a field named "contents".  Specify a Reader,
  +    // so that the text of the file is tokenized and indexed, but not stored.
       // ?? why doesn't FileReader work here ??
       FileInputStream is = new FileInputStream(f);
       Reader reader = new BufferedReader(new InputStreamReader(is));
  -    doc.add(Field.Text("contents", reader));
  +    doc.add(new Field("contents", reader));
   
       // return the document
       return doc;
  
  
  

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