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 00:27:44 UTC

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

dnaber      2004/09/01 15:27:44

  Modified:    src/demo/org/apache/lucene/demo HTMLDocument.java
  Log:
  start using the non-deprecated API
  
  Revision  Changes    Path
  1.5       +16 -17    jakarta-lucene/src/demo/org/apache/lucene/demo/HTMLDocument.java
  
  Index: HTMLDocument.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/demo/org/apache/lucene/demo/HTMLDocument.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- HTMLDocument.java	6 Aug 2004 19:26:16 -0000	1.4
  +++ HTMLDocument.java	1 Sep 2004 22:27:44 -0000	1.5
  @@ -45,21 +45,21 @@
       // make a new, empty document
       Document doc = new Document();
   
  -    // Add the url 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().replace(dirSep, '/')));
  +    // Add the url 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().replace(dirSep, '/'), 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 uid as a field, so that index can be incrementally maintained.
       // This field is not stored with document, it is indexed, but it is not
       // tokenized prior to indexing.
  -    doc.add(new Field("uid", uid(f), false, true, false));
  +    doc.add(new Field("uid", uid(f), Field.Store.NO, Field.Index.UN_TOKENIZED));
   
       FileInputStream fis = null;
       try {
  @@ -68,15 +68,14 @@
         
         // Add the tag-stripped contents as a Reader-valued Text field so it will
         // get tokenized and indexed.
  -      doc.add(Field.Text("contents", parser.getReader()));
  +      doc.add(new Field("contents", parser.getReader()));
   
  -      // Add the summary as an UnIndexed field, so that it is stored and returned
  -      // with hit documents for display.
  -      doc.add(Field.UnIndexed("summary", parser.getSummary()));
  +      // Add the summary as a field that is stored and returned with
  +      // hit documents for display.
  +      doc.add(new Field("summary", parser.getSummary(), Field.Store.YES, Field.Index.NO));
   
  -      // Add the title as a separate Text field, so that it can be searched
  -      // separately.
  -      doc.add(Field.Text("title", parser.getTitle()));
  +      // Add the title as a field that it can be searched and that is stored.
  +      doc.add(new Field("title", parser.getTitle(), Field.Store.YES, Field.Index.TOKENIZED));
       } finally {
         if (fis != null)
           fis.close();
  
  
  

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