dnn 7+搜索未为自定义模块项目编制索引 [英] dnn 7+ search is not indexing custom module items

查看:97
本文介绍了dnn 7+搜索未为自定义模块项目编制索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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.

以上代码中的任何项目均未添加到索引中.我什至使用Luke Inspector来检查lucene索引,并确认没有添加这些项目.

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.

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

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.

预先感谢

JK

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

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

exec GetSearchModules[PortalId]

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

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.

因此,我升级到7.3.1,希望安装期间的某些操作可以解决此问题.但事实并非如此.通过GetModifiedSearchDocuments函数仍可以创建/返回搜索文档,但是这些文档没有添加到Lucene索引中,因此不会出现在搜索结果中.

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.

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

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

编辑#4

好的,我在以下三个有关DNN问题跟踪器的讨论中修改了问题,但仍未将任何项目添加到lucene索引中.

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:

{类型为'Lucene.Net.Index.MergePolicy + MergeException'的异常"为 抛出.} {"无法覆盖: C:\ websites \ dnndev.me \ App_Data \ Search \ _1f0.fdt}

{"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

推荐答案

J King,

我刚刚在DNNHero.com上的

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.

在您的实现中删除您对SearchTypeId的分配

此外,这是一个示例片段,以查看我如何设置SearchDocument的属性.再次,观看我的视频,了解Search实施中的其他所有潜在陷阱.

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
        };

这篇关于dnn 7+搜索未为自定义模块项目编制索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆