使用 Vulcan elastic search for EPiServer 的映射错误

Mapping errors using Vulcan elastic search for EPiServer

有没有人用过EPiServer的elasticsearch客户端叫Vulcan? (https://github.com/TCB-Internet-Solutions/vulcan)

从所有人的角度来看(包括这个写得很好的:https://blog.wsol.com/getting-started-using-vulcan-search-in-episerver),它应该像从 EPiServer NuGet 提要安装 NuGet 包 "TcbInternetSolutions.Vulcan.Core" 一样简单,添加 web.config 设置,并 运行 将计划的作业编入索引数据。

我将 NuGet 包(版本 3.0.1)安装到我的 EPiServer 项目(版本 11.2.1)中并设置了我的 web.config 设置和索引作业报告 "The job has completed. Please refresh the page to see the status." [=42] =] 历史显示 "Vulcan successfully indexed 100 item(s) across 1 indexers!".

但是,当我查看“\App_Data\EPiServerErrors.log”文件时,我看到大量错误,例如:

ERROR TcbInternetSolutions.Vulcan.Core.Implementation.VulcanClient: Vulcan could not index content with content link 10 for language en: System.Exception: Invalid NEST response built from a unsuccessful low level call on PUT: /customername_en/EPiServer.Core.BlockData/10 Audit trail of this API call: - [1] BadResponse: Node: http://localhost:9200/ Took: 00:00:00.4026489 ServerError: ServerError: 400Type: mapper_parsing_exception Reason: "failed to find type parsed [string] for [contentAssetsID]" OriginalException: System.Net.WebException: The remote server returned an error: (400) Bad Request. at System.Net.HttpWebRequest.GetResponse() at Elasticsearch.Net.HttpConnection.Request[TReturn](RequestData requestData) in C:\Projects\elastic\net-2\src\Elasticsearch.Net\Connection\HttpConnection.cs:line 163

似乎无法在索引 "customername_en" 中为类型 "EPiServer.Core.BlockData" 建立索引,因为当“[contentAssetsID]”应该是一个数字时,所有内容都默认映射到一个字符串.所以我尝试添加一个初始化 class 以将映射设置为 AutoMap:

[ModuleDependency(typeof(ServiceContainerInitialization))]
public class SearchInitialization : IConfigurableModule
{
    public void ConfigureContainer(ServiceConfigurationContext context)
    {
        // Nothing to do
    }

    public void Initialize(InitializationEngine context)
    {
        var vh = ServiceLocator.Current.GetInstance<VulcanHandler>();
        var vhClient = vh.GetClient(new System.Globalization.CultureInfo("en"));
        var res = vhClient.Map<EPiServer.Core.BlockData>(m => m.AutoMap());
    }

    public void Uninitialize(InitializationEngine context)
    {
        // Nothing to do
    }
}

"res" returns响应成功,但仍然出现错误。

这里有完整的错误:https://pastebin.com/T7NPgZj9

请帮忙!

多亏了 Dimitar,我使用的是 ElasticSearch 5 而不是 2。更改为版本 2 后它起作用了。