I created a website but i have a problem. i want to build once an index und use it.
at the moment i have two functions "create a document an store it into the directory" and "searching"
when the user submit:
sub submit ()
create_doc()
search(text)
end sub
this works, but when i try this:
create_doc()
sub submit()
search(text)
end sub
it s like the directory has been deleted.
global:
Dim analyzer As StandardAnalyzer = New StandardAnalyzer()Dim directory As Directory = FSDirectory.GetDirectory("C:[...]luceneindex", True)
Dim indexwriter As IndexWriter = New IndexWriter(directory, analyzer, True)
Sub create_doc()
Dim meindoc As New Document()
im feldbodytext As Field = New Field("bodytext", textstring[...]
meindoc.Add(feldbodytext)
indexwriter.AddDocument(meindoc)
indexwriter.Close()
end sub
Sub lucene_search(ByVal strSuchbegriff As String)
Dim parser As QueryParser = New QueryParser("bodytext", analyzer)
Dim query As Query = parser.Parse(strSuchbegriff)
Dim hits As Hits = searcher.Search(query)
[...]
end sub
Is there a possibility to store the index permanently? could there be a problem init. the index writer gloabel, but close it local?