字典中没有给定的键。 -异常Solrnet和CommonServicelocator

问题描述 投票:0回答:1

我们正在Sitecore CMS中使用SolrNet,它在Solr上也有一个包装。但是,为了利用SolrNet中的功能,我们倾向于使用Solrnet。

我已经升级了此sitecore应用程序,看起来它还为Solr初始化了ServiceLocator。这与Solrnet ServiceLocator冲突。下面是我们用于初始化Solrnet的代码和错误堆栈跟踪。我不确定如何调试或解决此错误,要求任何人请为此提供一些指针,或者以前曾见过此错误。

Startup.Init(loggingSolrConnection);

Solrnet版本-1.0.13,也尝试使用最新的1.0.19。 Bin文件夹包含-Commonservicelocator.dllCommonServicelocator.solrnet.dll

The given key was not present in the dictionary.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:
[KeyNotFoundException: The given key was not present in the dictionary.]
   System.ThrowHelper.ThrowKeyNotFoundException() +36
   System.Collections.Generic.Dictionary`2.get_Item(TKey key) +52
   SolrNet.Utils.Container.DoGetInstance(Type serviceType, String key) +25
   CommonServiceLocator.ServiceLocatorImplBase.GetInstance(Type serviceType, String key) +54

[ActivationException: Activation error occurred while trying to get instance of type ISolrMoreLikeThisHandlerQueryResultsParser`1, key ""]
   CommonServiceLocator.ServiceLocatorImplBase.GetInstance(Type serviceType, String key) +155
   CommonServiceLocator.ServiceLocatorImplBase.GetInstance() +54
solr sitecore solrnet service-locator common-service-locator
1个回答
0
投票

Sitecore旨在从开发人员中抽象搜索引擎的实现,因此可以在后台使用Solr / Azure Search / Elastic Search / Coveo /(任何其他引擎)。

尽管错误表明缺少ISolrMoreLikeThisHandlerQueryResultsParser注册,应该通过Sitecore.ContentSearch.SolrProvider.SolrNetIntegration.DefaultSolrLocator.Initialize将其添加到OOB Sitecore或通过SolrNet.Startup.InitContainer API来添加到SOLR本机,但我鼓励您避免直接处理SOLR并使用Sitecore APIs instead

否则,您可能会因绕过Sitecore逻辑而遇到不同的行为。

请您简单说明一下OOB Sitecore API不够的原因/用例吗?

© www.soinside.com 2019 - 2024. All rights reserved.