1

I add a custom computed field to the fieldmap node in the Lucene Search config like so:

<fieldNames hint="raw:AddFieldByFieldName">
 <field fieldName="my_field" indexType="UNTOKENIZED" returnType="stringCollection" />
</fieldNames>

I also registered my custom computed field like so:

<fields hint="raw:AddComputedIndexField">
 <field fieldName="my_field" indexType="UNTOKENIZED" returnType="stringCollection">MyAssembly.MyField,MyAssembly</field>
</fields>

After saving and building the solution I got this error when logging into Sitecore:

contextDatabase

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.InvalidOperationException: contextDatabase

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:

[InvalidOperationException: contextDatabase]
Sitecore.Forms.Core.Dependencies.DefaultImplItemRepository..ctor(Database contextDatabase, Database masterDatabase) +103

Further Information: Sitecore 8.2 update 6.

1

I am not sure what the issue was but in the end to fix this I had to update by field to:

<fieldNames hint="raw:AddFieldByFieldName">
    <field fieldName="my_field" indexType="UNTOKENIZED" returnType="stringCollection" storageType="YES" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider">
        <analyzer type="Sitecore.ContentSearch.LuceneProvider.Analyzers.LowerCaseKeywordAnalyzer, Sitecore.ContentSearch.LuceneProvider" />
    </field>
</fieldNames>

I thought it might be the self-closing tag but I tried just updating that and that that didn't resolve the issue so i'm assuming it is either the settingType attribute or child node that solved this issue.

If anyone has a better solution please let me know.

| improve this answer | |
  • I always thought the analyzer was required along with the other fields you added. Alternatively you can pass a string that is a JSON format. I have done that for things that require a lot of data. Then convert the value. I have an example if you want to go that route. – RReilley Apr 3 '18 at 13:24
  • Thanks Rob. I saw a few examples without the analyzer so figured it should work but it doesn't seem to. Maybe I'm just missing something else though. – Adam Seabridge Apr 3 '18 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.