简体   繁体   English

字典中不存在给定的键。 - 异常 Solrnet 和 CommonServicelocator

[英]The given key was not present in the dictionary. - Exception Solrnet and CommonServicelocator

We are using SolrNet in Sitecore CMS , which also has a wrapper over the Solr.我们在 Sitecore CMS 中使用 SolrNet,它也有一个对 Solr 的封装。 But to leverage the features in SolrNet , we have preferred to use Solrnet.但是为了利用 SolrNet 中的功能,我们更喜欢使用 Solrnet。

I have upgraded this sitecore application and it looks like it also initializes a ServiceLocator for Solr.我已经升级了这个 sitecore 应用程序,它看起来也为 Solr 初始化了一个 ServiceLocator。 this is clashing with the Solrnet ServiceLocator.这与 Solrnet ServiceLocator 发生冲突。 Below is the code and error stack trace we are using for initalizing Solrnet.下面是我们用于初始化 Solrnet 的代码和错误堆栈跟踪。 I am not sure how to debug or resolve this error, request anyone to please provide some pointers for this or has seen this error before.我不确定如何调试或解决此错误,请任何人为此提供一些指示,或者之前曾见过此错误。

Startup.Init(loggingSolrConnection); Startup.Init(loggingSolrConnection);

Solrnet version - 1.0.13 , also tried with latest 1.0.19. Solrnet 版本 - 1.0.13 ,也尝试使用最新的 1.0.19。 Bin folder contains - Commonservicelocator.dll and CommonServicelocator.solrnet.dll 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

Sitecore is designed to abstract search engine implementation from the developer, so that Solr/Azure Search/Elastic Search/Coveo/(any other engine) could be used under the hood. Sitecore 旨在从开发人员那里抽象出搜索引擎实现,以便可以在后台使用 Solr/Azure Search/Elastic Search/Coveo/(任何其他引擎)。

Although the error indicates a lack of ISolrMoreLikeThisHandlerQueryResultsParser registration that ought be added to OOB Sitecore via Sitecore.ContentSearch.SolrProvider.SolrNetIntegration.DefaultSolrLocator.Initialize or to SOLR native via SolrNet.Startup.InitContainer API, I would encourage you to avoid dealing with SOLR directly and use Sitecore APIs instead .虽然错误指示缺少ISolrMoreLikeThisHandlerQueryResultsParser登记,本应通过被添加到OOB Sitecore的Sitecore.ContentSearch.SolrProvider.SolrNetIntegration.DefaultSolrLocator.Initialize或通过SOLR本地SolrNet.Startup.InitContainer API,我会鼓励你避免直接处理SOLR并改用Sitecore API

Otherwise you might experience different behavior caused by bypassing Sitecore logic.否则,您可能会遇到因绕过 Sitecore 逻辑而导致的不同行为。

Could you please brief the reasons/use cases when OOB Sitecore API is not enough?您能否简要介绍一下 OOB Sitecore API 不够用的原因/用例?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM