簡體   English   中英

字典中不存在給定的鍵。 - 異常 Solrnet 和 CommonServicelocator

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

我們在 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

Sitecore 旨在從開發人員那里抽象出搜索引擎實現,以便可以在后台使用 Solr/Azure Search/Elastic Search/Coveo/(任何其他引擎)。

雖然錯誤指示缺少ISolrMoreLikeThisHandlerQueryResultsParser登記,本應通過被添加到OOB Sitecore的Sitecore.ContentSearch.SolrProvider.SolrNetIntegration.DefaultSolrLocator.Initialize或通過SOLR本地SolrNet.Startup.InitContainer API,我會鼓勵你避免直接處理SOLR並改用Sitecore API

否則,您可能會遇到因繞過 Sitecore 邏輯而導致的不同行為。

您能否簡要介紹一下 OOB Sitecore API 不夠用的原因/用例?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM