BrainDump
  Home arrow BrainDump arrow Page 4 - Working with Lucene.Net
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
BRAINDUMP

Working with Lucene.Net
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 9
    2007-08-16

    Table of Contents:
  • Working with Lucene.Net
  • Using Lucene.Net
  • Creating an index
  • Adding data to a document
  • Searching an index

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Working with Lucene.Net - Adding data to a document


    (Page 4 of 5 )

    Once you’ve created a Document, you’ll need to add data to it. This is done by creating one or more Fields for each piece of metadata in your file. For example, in the sample application, we created aFieldcalledpaththat holds the path to the file we are indexing, aFieldcalledmodifiedthat holds the date the file was last modified, and aFieldcalledcontentsthat holds the document’s raw text content. You can create moreFields as your application requires. When you create aField, you can also specify what type ofFieldit is.

    The threeFields in our sample application are added to aDocumentlike so:

      doc.Add(new Field("path", f.FullName, Field.Store.YES,
                     Field.Index.UN_TOKENIZED));

      doc.Add(new Field("modified",
                      
    DateTools.TimeToString(f.LastWriteTime.Ticks,
                  
    DateTools.Resolution.MINUTE), Field.Store.YES,
                  
    Field.Index.UN_TOKENIZED));

      doc.Add(new Field("contents", new System.IO.StreamReader(f.FullName, 
                System.Text.Encoding.Default)));

    After you’ve populated aDocument object withFieldobjects, you’re ready to add theDocument to the index:

      writer.AddDocument(IndexDocument(file));

    Running the IndexFiles application.  From the command line, run theIndexFilesapplication against the folder you have populated with raw text files. You can also simply pointIndexFilesto the Lucene.Net source directory, andIndexFileswill index the Lucene.Net source files for you. To startIndexFiles, issue the following command from the bin directory:IndexFiles C:\Lucene.Net\. OnceIndexFilesis done indexing your files, it creates a directory called index in the current directory and stores the index in it.

    More BrainDump Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Windows Developer Power Tools," published...
       · heygreat article..but i guess the current update is not reflected. While using...
       · In case anybody hits this snag, the syntax has changed in the latest...
     

    Buy this book now. This article is excerpted from chapter four of the book Windows Developer Power Tools, written by James Avery and Jim Holmes (O'Reilly; ISBN: 0596527543). Check it out today at your favorite bookstore. Buy this book now.

    BRAINDUMP ARTICLES

    - Internet Explorer 8 Review
    - Nilpo`s Top Windows Add-Ons
    - Beginning Silverlight 2.0 Development using ...
    - Fixing Vista`s Troubles
    - Preparing Windows Images for Mass Deployment
    - The Trouble With Vista
    - Slipstreamed and Unattended Windows Installa...
    - Microsoft Office SharePoint Server
    - Microsoft Office SharePoint Designer
    - Microsoft Windows SharePoint Services 3.0
    - Microsoft Live Mesh Overview
    - XAML Brushes and Silverlight
    - Silverlight and XAML Basics
    - Immortal XP
    - XAML Basics





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT