0

I have updated a large application from .Net 4.0 to .Net 4.52 and it has broken some indexing and search functions that I have that use Lucene. I updated to the latest NuGet Packages for Lucene and I keep getting the following errors. Type 'Lucene.Net.Index.IndexWriter' is not defined. Type 'Lucene.Net.Documents.Document' is not defined. Type 'IndexWriter' is not defined. To name a few. The search functions were originally written by another developer so I am not completely familiar with it but it looks like they may have moved some namespaces when they updated Lucene to 3.0.3 but I can't find what they updated to. Any help would be greatly appreciated! Thanks Code Example Below References:

Imports Microsoft.WindowsAzure.Storage.Blob
Imports Microsoft.WindowsAzure.Storage
Imports Lucene.Net
Imports Lucene.Net.Documents
Imports Lucene.Net.Store

Imports Lucene.Net.Index
Imports Lucene.Net.Analysis

The Lucene.Net.Store says it doesn't contain any public members.

Example function that says Lucene.Net.Index.IndexWriter is not defined

 Private Function IndexNewDocument(id As String, savePath As String, targetContainer As String, indexer As Lucene.Net.Index.IndexWriter, b As CloudBlockBlob) As Boolean
    Dim sw As Stopwatch = Stopwatch.StartNew

    Dim filename As String = ""
    Dim dt As DateTime = Now

    Try
        ' Retrieve the document and pull the metadata for reindexing
        Dim docReturn As DocumentReturn = DocumentDownloadAdapter.GetDocument(_StorageEndpoint, _NewDocumentContainerName, id)
        filename = docReturn.Filename
        dt = docReturn.DateAdded

        ' Get the blob reader for indexing
        Dim docReader As IBlobDocumentReader = FileProcessor.GetBlobDocumentReader(docReturn.FileBytes, docReturn.Filename, savePath)

        ' push the index to the blob storage database
        pushIndexDocument(id, filename, dt, docReader, indexer)

        sw.Stop()
        OnDocumentIndexSuccessful(id, filename, sw.Elapsed)

        Return True
    Catch ex As EmptyPDFException
        CommonCodeLib.ErrorReport("AzureStorageAccountAdapter.indexDocument", ex, "")

        ' DELETE FILE FROM NEW BLOB INDEX
        Try
            b.Delete()
        Catch exDelete As Exception
            CommonCodeLib.ErrorReport("AzureStorageAccountAdapter.indexDocument: Problem Deleting blob", exDelete, "")
        End Try

        Try
            Dim username As String = getDocumentUsername(targetContainer, id)
            EmailAdapter.SendExceptionEmail(ex, GetEmailList(ConfigurationHelper.IndexEmailToList), GetEmailList(ConfigurationHelper.IndexEmailCCList), username)
        Catch exEmail As Exception
            CommonCodeLib.ErrorReport("AzureStorageAccountAdapter.indexDocument: Problem Emailing Exception", exEmail, "")
        End Try

        Return False
    Catch ex As InvalidDocumentTypeException
        CommonCodeLib.ErrorReport("AzureStorageAccountAdapter.indexDocument", ex, "")

        ' DELETE FILE FROM NEW BLOB INDEX
        Try
            b.Delete()
        Catch exDelete As Exception
            CommonCodeLib.ErrorReport("AzureStorageAccountAdapter.indexDocument: Problem Deleting blob", exDelete, "")
        End Try

        Try
            Dim username As String = getDocumentUsername(targetContainer, id)
            EmailAdapter.SendExceptionEmail(ex, GetEmailList(ConfigurationHelper.IndexEmailToList), GetEmailList(ConfigurationHelper.IndexEmailCCList), username)
        Catch exEmail As Exception
            CommonCodeLib.ErrorReport("AzureStorageAccountAdapter.indexDocument: Problem Emailing Exception", exEmail, "")
        End Try

        Return False
    Catch ex As Exception
        CommonCodeLib.ErrorReport("AzureStorageAccountAdapter.indexDocument", ex.ToString, "")
        sw.Stop()
        OnDocumentIndexFailed(id, filename, sw.Elapsed, ex)

        Return False
    End Try
End Function
Brian B
  • 35
  • 2
  • 6
  • Please show your code. – NightOwl888 Aug 18 '17 at 23:24
  • I added the code. Thanks! – Brian B Aug 19 '17 at 20:27
  • Since the code you supplied doesn't reference `IndexWriter`, it is not possible to determine what the problem is based on the question. I suspect based on the error you are getting that you have only upgraded part of your project to Lucene.Net 3.0.3. You need to [manually review the relevant files](https://stackoverflow.com/a/35991676) (project files, config files, and all dependencies) to ensure all of the version numbers match. – NightOwl888 Aug 19 '17 at 22:25
  • The reference is in the function line. "indexer As Lucene.Net.Index.IndexWriter", I have re-added all of the references that were originally in the project. I cannot find the namespace that calls the indexWriter. Same with documents. – Brian B Aug 20 '17 at 14:31

0 Answers0