Sitecore 8.1 Update-3 throw" String未被识别为有效的DateTime。"在管理界面

时间:2016-07-11 17:39:40

标签: sitecore lucene.net sitecore8

在升级到Sitecore 8.1之后的某个时刻(我们目前正在使用Update-3),我们开始在ELMAH中看到以下错误:

  

字符串未被识别为有效的DateTime。

下面的完整堆栈跟踪。

System.FormatException: Could not map index document field to property "CreatedDate" on type Sitecore.ContentSearch.SearchTypes.SitecoreUISearchResultItem : String was not recognized as a valid DateTime. ---> System.FormatException: String was not recognized as a valid DateTime.
at System.DateTimeParse.ParseExact(String s, String format, DateTimeFormatInfo dtfi, DateTimeStyles style)
at Sitecore.ContentSearch.Converters.IndexFieldDateTimeValueConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at Sitecore.ContentSearch.Converters.IndexFieldUtcDateTimeValueConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at Sitecore.ContentSearch.Converters.IndexFieldStorageValueFormatter.ReadFromIndexStorage(Object indexValue, String fieldName, Type destinationType)
at Sitecore.ContentSearch.DocumentTypeMapInfo.SetProperty(Object target, String propertyName, String documentFieldName, Object value)
--- End of inner exception stack trace ---
at Sitecore.ContentSearch.DocumentTypeMapInfo.SetProperty(Object target, String propertyName, String documentFieldName, Object value)
at Sitecore.ContentSearch.DefaultDocumentMapper`1.MapFieldValuesToType[TElement](IDictionary`2 fieldValues, TElement result, DocumentTypeMapInfo documentTypeMapInfo)
at Sitecore.ContentSearch.DefaultDocumentMapper`1.MapToType[TElement](TDocument document, SelectMethod selectMethod, IEnumerable`1 virtualFieldProcessors, IEnumerable`1 executionContexts, SearchSecurityOptions securityOptions)
at Sitecore.ContentSearch.LuceneProvider.LuceneSearchResults`1.<GetSearchHits>d__2.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at ItemBuckets.Services.Search.<ProcessRequestAsync>d__c.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.TaskAsyncHelper.EndTask(IAsyncResult ar)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

可以通过登录Sitecore Desktop并打开内容编辑器(Sitecore按钮&gt;内容编辑器)来重现这一点。

前段时间我发现Indexing DateTime fields – Sitecore 7 Content Search实现了8.1,导致补丁配置如下:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
    <sitecore>
        <!-- Override Include\Sitecore.ContentSearch.Lucene.DefaultIndexConfiguration.config to work around possible bug. -->
        <contentSearch>
            <indexConfigurations>
                <defaultLuceneIndexConfiguration type="Sitecore.ContentSearch.LuceneProvider.LuceneIndexConfiguration, Sitecore.ContentSearch.LuceneProvider">
                    <fieldMap type="Sitecore.ContentSearch.FieldMap, Sitecore.ContentSearch">
                        <fieldNames hint="raw:AddFieldByFieldName">
                            <field fieldName="__smallcreateddate">
                                <patch:attribute name="format">yyyyMMdd</patch:attribute>
                            </field>
                            <field fieldName="__smallupdateddate">
                                <patch:attribute name="format">yyyyMMdd</patch:attribute>
                            </field>
                        </fieldNames>
                    </fieldMap>
                </defaultLuceneIndexConfiguration>
            </indexConfigurations>
        </contentSearch>
    </sitecore>
</configuration>

这是解决此问题的最佳解决方案,还是有错误配置的内容?

0 个答案:

没有答案