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 Liu is a Sitecore MVP with expertise in all aspects of ASP.NET and SQL Server development across a variety of industries including Government, Banking, Healthcare and Energy. He provides technical thought leadership and consulting to SymSoft and client development teams. Xing has deep expertise in using Sitecore Helix in an Agile delivery model to streamline the construction of complex Sitecore websites, portals and their associated authoring environments. Xing is also a globally recognized photographer with an Instagram following approaching 100,000.

Explore topics:

Other Blog Posts from Xing Liu