0

我在本地机器上的 dnndev.me 下运行了一个 dnn 7.2.2 开发站点。我创建了一个简单的产品目录模块,并正在尝试集成对 dnn 7 的新搜索。

这是我的功能/业务控制器中 ModuleSearchBase 的实现

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

我清除了站点缓存,然后手动启动了搜索重新索引。我可以从主机计划历史记录中看到重新索引已运行并完成。

问题

上述代码中的所有项目均未添加到索引中。我什至使用 Luke Inspector 查看了 lucene 索引,并确认没有添加这些项目。

问题

我需要帮助弄清楚为什么没有添加这些项目,或者我需要有关如何调试索引以查看在该过程中是否有任何运行的帮助。

提前致谢

JK

编辑#1

我在 Sql Server 中运行了以下过程,以查看该模块是否甚至列在搜索模块中:

exec GetSearchModules[PortalId]

有问题的模块确实出现在此列表中。为 featureController 调用索引,但结果不会添加到 lucene 索引中。仍然需要帮助。

编辑#2

所以我升级到 7.3.1,希望在安装过程中能解决这个问题。但它没有。GetModifiedSearchDocuments 函数仍在创建/返回搜索文档,但这些文档并未添加到 Lucene 索引中,因此不会出现在搜索结果中。

编辑#3

升级后断点没有像我想的那样被击中,但是我添加了一个 try catch 来记录异常,并且当我尝试手动重新索引时会创建以下错误日志(清理以保持简短)

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

编辑#4

好的,我在 DNN 问题跟踪器上的 This Disucssion 之后的编辑三中修复了该问题,但仍未将任何项目添加到 lucene 索引中。

断点被击中,一旦我让调试器运行一段时间,我会收到以下错误:

{“引发了 'Lucene.Net.Index.MergePolicy+MergeException' 类型的异常。”} {“无法覆盖:C:\websites\dnndev.me\App_Data\Search\_1f0.fdt”}

看起来像是权限错误。我会看看我能解决什么问题

4

1 回答 1

3

Ĵ国王,

我刚刚在 DNNHero.com 上完成了关于在您的模块中实施搜索的系列文章。第 3 部分和第 4 部分正在实现和调试您的 ModuleSearchBase 实现。

编辑:在您的实施中删除您对 SearchTypeId 的分配

此外,这是一个示例片段,可以查看我如何设置 SearchDocument 的属性。再次,观看我的视频,了解搜索实施中的一大堆其他潜在缺陷。

        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
        };
于 2014-07-24T17:14:13.487 回答