dnn 7+ search is not indexing custom module items

允我心安 提交于 2019-12-13 21:30:15

问题


I have a dnn 7.2.2 development site running under dnndev.me on my local machine. I have created a simple product catalogue module and am trying to integrate the new search for dnn 7.

Here is the implementation of ModuleSearchBase in my feature/business controller

Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Search
Imports DotNetNuke.Common.Globals

Namespace Components

    Public Class FeatureController
        Inherits ModuleSearchBase
        Implements IUpgradeable


        Public Overrides Function GetModifiedSearchDocuments(moduleInfo As ModuleInfo, beginDate As Date) As IList(Of Entities.SearchDocument)

         Try

            Dim SearchDocuments As New List(Of Entities.SearchDocument)

            'get list of changed products
            Dim vc As New ViewsController
            Dim pList As List(Of vw_ProductList_Short_Active) = vc.GetProduct_Short_Active(moduleInfo.PortalID)

            If pList IsNot Nothing Then
                ''for each product, create a searchdocument
                For Each p As vw_ProductList_Short_Active In pList

                    Dim SearchDoc As New Entities.SearchDocument

                    Dim ModID As Integer = 0
                    If p.ModuleId Is Nothing OrElse p.ModuleId = 0 Then
                        ModID = moduleInfo.ModuleID
                    Else
                        ModID = p.ModuleId
                    End If

                    Dim array() As String = {"mid=" + ModID.ToString, "id=" + p.ProductId.ToString, "item=" + Replace(p.Name, " ", "-")}
                    Dim DetailUrl = NavigateURL(moduleInfo.TabID, GetPortalSettings(), "Detail", array)

                    With SearchDoc
                        .AuthorUserId = p.CreatedByUserId
                        .Body = p.ShortInfo
                        .Description = p.LongInfo
                        .IsActive = True
                        .PortalId = moduleInfo.PortalID
                        .ModifiedTimeUtc = p.LastUpdatedDate
                        .Title = p.Name + " - " + p.ProductNumber
                        .UniqueKey = Guid.NewGuid().ToString()
                        .Url = DetailUrl
                        .SearchTypeId = 2
                        .ModuleId = p.ModuleId
                    End With

                    SearchDocuments.Add(SearchDoc)
                Next

                Return SearchDocuments

            Else
                Return Nothing
            End If

        Catch ex As Exception
            LogException(ex)
            Return Nothing
        End Try

        End Function
    End Class

End Namespace

I cleared the site cache and then I manually started a search re-index. I can see from the host schedule history that the re-index is run and completes.

PROBLEM

None of the items in the above code are added to the index. I even used the Luke Inspector to look into the lucene index and that confirms that these items are not added.

QUESTION

I need help figuring out why these items are not getting added or I need help on how to debug the indexing to see if anything is going run during that process.

Thanks in Advance

JK

EDIT #1

I ran the following procedure in Sql Server to see if the module is even listed in the search modules:

exec GetSearchModules[PortalId]

The module in question does appear in this list. The indexing is called for the featureController, but the results are not added to the lucene index. Still need help.

EDIT #2

So I upgraded to 7.3.1 in the hopes that something during the installation would fix this issue. But it did not. The search documents are still getting created/ returned by the GetModifiedSearchDocuments function but the documents are not being added to the Lucene index and therefore do not appear in the search results.

EDIT #3

The break point is not getting hit like i thought after the upgrade, but I added a try catch to log exceptions and the following error log is getting created when I try to manually re-index (cleaned up to keep it short)

AssemblyVersion:7.3.1
PortalID:-1
PortalName:    
DefaultDataProvider:DotNetNuke.Data.SqlDataProvider, DotNetNuke
ExceptionGUID:d0a443da-3d68-4b82-afb3-8c9183cf8424
InnerException:Sequence contains more than one matching element
Method:System.Linq.Enumerable.Single
StackTrace:
Message:
System.InvalidOperationException: Sequence contains more than one matching element
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
   at DotNetNuke.Services.Scheduling.Scheduler.CoreScheduler.LoadQueueFromTimer()
   at DotNetNuke.Services.Scheduling.Scheduler.CoreScheduler.Start()
Source:
Server Name: KING-PC

EDIT #4

Okay, I fixed the problem in edit three following This Disucssion on the DNN issue tracker, but still no items being added to the lucene index.

The breakpoint is hit, and once i leave the debugger running for a while i get the following error:

{"Exception of type 'Lucene.Net.Index.MergePolicy+MergeException' was thrown."} {"Cannot overwrite: C:\websites\dnndev.me\App_Data\Search\_1f0.fdt"}

Looks like a permission error. I'll see what I can work out


回答1:


J King,

I just finished a series on DNNHero.com on Implementing Search in your Module. Parts 3 and 4 are implementing and debugging your ModuleSearchBase implementation.

EDIT: Remove your assignment to the SearchTypeId in your implementation

Also, here is a sample snippet to see how i am setting the attributes of the SearchDocument. Again, watch my video for a whole bunch of other potential pitfalls in the Search implementation.

        SearchDocument doc = new SearchDocument
        {
            UniqueKey = String.Format("{0}_{1}_{2}",
                    moduleInfo.ModuleDefinition.DefinitionName, moduleInfo.PortalID, item.ItemId),
            AuthorUserId = item.AssignedUserId,
            ModifiedTimeUtc = item.LastModifiedOnDate.ToUniversalTime(),
            Title = item.ItemName,
            Body = item.ItemDescription,
            Url = "",
            CultureCode = "en-US",
            Description = "DotNetNuclear Search Content Item",
            IsActive = true,
            ModuleDefId = moduleInfo.ModuleDefID,
            ModuleId = item.ModuleId,
            PortalId = moduleInfo.PortalID,
            TabId = tab
        };


来源:https://stackoverflow.com/questions/24918939/dnn-7-search-is-not-indexing-custom-module-items

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!