我正在使用下面的代码,但它提供了很多文件,我只想要一个xml格式的文件,所以请给我一个正确的方法来创建xml格式的lucene索引。
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
请给我一个正确的方法,只在一个xml格式的文件中创建一个lucene索引。