在 Sitecore 中索引双精度字段时出现本地化问题



我在使用 Sitecore 7.5 和 Lucene 索引时遇到问题。我有带有"纬度"单行文本字段的项目。此字段存储带点(非逗号(的双精度数字。我将计算机上的区域性设置为 en-US,因此它应该适用于这样的数字。我也设置了相同的IIS区域性。但是当我重建索引时,出现以下错误:

17840 01:46:43 FATAL Could not add field {25D5A28F-F502-42CE-8FDD-C6432E64AE67} : latitude for indexable sitecore://web/{94D5DBF1-FEB9-464B-B887-A99181B58268}?lang=en&ver=1
Exception: System.FormatException
Message: Input string was not in a correct format.
Source: mscorlib
   at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)
   at System.String.System.IConvertible.ToDouble(IFormatProvider provider)
   at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
   at Sitecore.ContentSearch.LuceneProvider.LuceneFieldBuilder.CreateField(String name, Object value, LuceneSearchFieldConfiguration fieldConfiguration, IIndexFieldStorageValueFormatter indexFieldStorageValueFormatter)
   at Sitecore.ContentSearch.LuceneProvider.LuceneDocumentBuilder.AddField(String name, Object value, LuceneSearchFieldConfiguration fieldSettings, Single boost)
   at Sitecore.ContentSearch.LuceneProvider.LuceneDocumentBuilder.AddField(IIndexableDataField field)
   at Sitecore.ContentSearch.AbstractDocumentBuilder`1.CheckAndAddField(IIndexable indexable, IIndexableDataField field)

我尝试调试这些方法,发现 System.Threading.Thread.CurrentThread.CurrentCulture 在 Sitecore.ContentSearch.LuceneProvider.LuceneFieldBuilder.CreateField(( 方法中是"ru-RU"。但是在我的 c# 代码中,我将 System.Threading.Thread.CurrentThread.CurrentCulture 设置为"en-US"。我在调试模式下检查了这一点。那么,在索引过程中,CurrentCulture怎么可能被改变呢?我在 Windows 或 IIS 区域性设置中都没有"ru-RU"设置。

@Andrei几个月前我遇到了同样的问题(在MS SQL中使用存储过程(。

我已在本地计算机 (Windows 10( 和 IIS 上将默认区域性更改为"en-US"。不幸的是,它没有帮助我。就我而言,我重写了我的存储过程,其中我用双精度数字替换了分隔符。

所以,这是一个非常复杂的问题。我认为您应该使用ENG版本的安装程序在本地计算机上重新安装操作系统。

尝试从命令行运行此代码:

appcmd set config /commit:WEBROOT /section:globalization /culture:en-us

它会将您的文化设置为"en-us"。

最新更新