Sitecore, Solr, CommerceServer config issues

784 Views Asked by At

just finishing converting a Sitecore 8.2 (w/ CommerceServer) instance to use Solr instead of Lucene. I have been following this article here:

http://blog.alpha-solutions.us/2016/10/how-to-use-solr-with-sitecore-8-2-with-solr-6-the-easy-way/

At the end of the setup my site / CMS give me this error:

Server Error in '/' Application.

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.Collections.Generic.Dictionary`2.get_Item(TKey key) +14331515 Sitecore.ContentSearch.SolrProvider.SolrFieldMap.AddFieldByFieldName(XmlNode configNode) +647

Any idea what this could be? I think maybe I am missing a config somewhere.

Thank you in advance.

2

There are 2 best solutions below

1
On BEST ANSWER

Check in your Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config file or a custom index configuration if you have one. There will be a field map section like this:

      <fieldMap type="Sitecore.ContentSearch.SolrProvider.SolrFieldMap, Sitecore.ContentSearch.SolrProvider">
        <fieldNames hint="raw:AddFieldByFieldName">
          <field fieldName="Yourfield" returnType="string" />
        </fieldNames/>
      </fieldMap>

The configuration for the fields will be wrong somewhere.

If you have a custom index configuration be sure to make sure the fieldMap element is set up like this with a ref rather than a type:

 <fieldMap ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration/fieldMap">
0
On

Make sure to include <typeMatches> before <fieldNames>.

<fieldMap ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration/fieldMap">
  <typeMatches hint="raw:AddTypeMatch"></typeMatches>
  <fieldNames hint="raw:AddFieldByFieldName">
        ....
  </fieldNames>
</fieldMap>