简体   繁体   中英

how to create a lucene index only in one readable xml format

I am using below code for it but its give so many files and I want only one file in xml format so pls give me a proper way to create a lucene index in xml format.

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

pls give me a proper way to create a lucene index only in one file in xml format.

Short answer: You can't.

Why would you want to do this, anyway? Performance would be terrible .

To get an overview of the different files lucene creates, take a look at Index File Formats .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM