lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Prescott Nasser <geobmx...@hotmail.com>
Subject RE: [Lucene.Net] Problem while creating index for the xml file
Date Tue, 17 May 2011 05:52:35 GMT

What's the issue your having? Seems like you're indexing the entire XML document as one field,
which likely isn't the best way to go
 
~P





----------------------------------------
> Date: Tue, 17 May 2011 11:04:30 +0530
> From: vlalithasivajyothi@gmail.com
> To: lucene-net-dev@lucene.apache.org
> Subject: [Lucene.Net] Problem while creating index for the xml file
>
> Dear Lucene team,
>
> I would like to create index files for the below xml file using
> Lucene.Net dll v2.9. I used the below code, but its not working.
> Please guide me to create index files for the below xml file. Thanks
> in advance
>
>
> 
> 
> 
> 8742656
> KDILI00D9L36
> 
> ORIGINAL
> ADD_1STPASS
> 25
> BN
> ENGLISH
> 20090115 13:30:00.000
> 2
> *U.S. INITIAL JOBLESS CLAIMS ROSE 54,000 TO 524,000
> LAST WEEK
> PLAIN
> China’s statistics bureau said it condemns leaks of
> economic data and those responsible
> 
> 
> 8742656
> KDILI03T6SQU
> 
> ORIGINAL
> ADD_1STPASS
> 25
> BN
> ENGLISH
> 20090115 13:30:00.000
> 0
> *U.S. INITIAL JOBLESS CLAIMS ROSE 54,000 TO 524,000
> LAST WEEK
> PLAIN
> China’s foreign-exchange reserves exceeded $3 trillion for
> the first time
> 
> 
> 
>
> Code
> ===========
> indexFileLocation = @"C:\Index";
> Lucene.Net.Store.Directory dir =
> FSDirectory.GetDirectory(indexFileLocation, true);
>
> //create an analyzer to process the text
> Lucene.Net.Analysis.Analyzer analyzer = new
> Lucene.Net.Analysis.Standard.StandardAnalyzer();
>
> IndexWriter indexWriter = new IndexWriter(indexFileLocation, new
> StandardAnalyzer(), true);
>
> TextReader txtReader = new StreamReader(@"C:\NewsMetaData.xml");
>
> //create a document, add in a single field
> Document doc = new Document();
> Field fldContent = new Field("contents", txtReader, Field.TermVector.YES);
>
> doc.Add(fldContent);
>
> //write the document to the index
> indexWriter.AddDocument(doc);
>
> //optimize and close the writer
> indexWriter.Optimize();
> indexWriter.Close(); 		 	   		  
Mime
View raw message