Lucene Sitecore Fields with Spaces

Xing Liu • 4/1/2016

While working with the Lucene content search API, we encountered an issue trying to search the field content that set storage type to YES. We had a Sitecore field name with space in it - “field name”. In the custom configuration, we added the following setting:

<field fieldName="field_name" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider">
  <analyzer type="Sitecore.ContentSearch.LuceneProvider.Analyzers.LowerCaseKeywordAnalyzer, Sitecore.ContentSearch.LuceneProvider" />
</field>

However, when we removed the space in the field name as well as in the configuration fieldname attribute, the Lucene search did return value from that field.

It turns out that this issue was documented in the Sitecore Knowledge Base. To resolve this problem, we need to add another configuration entry with spaces in the field name:

<field fieldName="field name" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider">
  <analyzer type="Sitecore.ContentSearch.LuceneProvider.Analyzers.LowerCaseKeywordAnalyzer, Sitecore.ContentSearch.LuceneProvider" />
</field>

Here is the link to the Knowledge Base: https://kb.sitecore.net/articles/036144

Xing Liu

Xing has 5 years of experience with developing web solutions using ASP.NET and SQL Server. For the past 3 years, he has been actively engaged in website development projects using Sitecore CMS. He enjoys creating web solutions for clients using Sitecore CMS and, using its flexibility, provides cohesive and integrated solutions. Xing is a Sitecore Technology MVP, 2016.

Explore topics:

Other Blog Posts from Xing Liu