Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using a below code for lucene index but its done in the many files i want only one file to lucene index its in xml file the code is
VB
Private Sub Create_Index_Click(sender As Object, e As RoutedEventArgs) Handles Create_Index.Click
       'Fetching Data from Databas

       Dim BibliDS As New DataSet
       Dim DataDS As New DataSet
       Dim dt As DataTable

       Dim strTagSbFld As String
       strTagSbFld = GetTagSbFldSQL()

       conn.Open()
       Dim strSQL As String = (strTagSbFld)
       adap.SelectCommand = New SqlCommand(strSQL, conn)
       adap.Fill(DataDS)
       conn.Close()
       DataDS.WriteXml("C:\Users\Shahrukh\Documents\Visual Studio 2012\Projects\Simple search1\Simple search1\New folder\Data.xml")
       'MsgBox("XML Done")
       Dim directory As Directory = FSDirectory.GetDirectory("C:\Users\Shahrukh\Documents\Visual Studio 2012\Projects\Simple search1\Simple search1\New folder ")

           Dim analyzer As Lucene.Net.Analysis.Analyzer = New SimpleAnalyzer()
           Dim indexWriter As New IndexWriter(directory, analyzer)
           indexWriter.SetRAMBufferSizeMB(10.0)
           indexWriter.SetUseCompoundFile(False)
           indexWriter.SetMaxMergeDocs(10000)
           indexWriter.SetMergeFactor(100)

           dt = DataDS.Tables(0)
           If dt IsNot Nothing Then
               If dt.Rows.Count > 0 Then
                   For Each dr As DataRow In dt.Rows
                       'Create the Document object
                       Dim doc As New Document()
                       For Each dc As DataColumn In dt.Columns
                           'Populate the document with the column name and value from our query
                           doc.Add(New Field(dc.ColumnName, dr(dc.ColumnName).ToString(), Field.Store.YES, Field.Index.TOKENIZED))
                       Next
                       ' Write the Document to the catalog
                       indexWriter.AddDocument(doc)
                   Next
               End If
           Else
               MsgBox("No Data")
           End If
           'indexWriter.Optimize()
           'Close the writer
           indexWriter.Flush()
           indexWriter.Close()

   End Sub


please provide me a proper way to create a lucene index only in xml file.
Posted
Updated 18-Nov-15 19:03pm
v3
Comments
Patrice T 19-Nov-15 1:09am    
Repost

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900