I just faced with the issue yesterday that I created my own search configuration to store only one field value in the index. I thought that it’s enough if I only index that one field what I want, but NOT.
So if you have something like this, then you will have duplicated entries in the index, because when you change the item and save/publish Lucene doesn’t know that you have already this in Index and it should be updated. So it creates a totally new entry with a different “_uniqueId”.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> | |
<sitecore> | |
<contentSearch> | |
<indexConfigurations> | |
<myOwnCustomLuceneIndexConfiguration type="Sitecore.ContentSearch.LuceneProvider.LuceneIndexConfiguration, Sitecore.ContentSearch.LuceneProvider"> | |
<fieldMap type="Sitecore.ContentSearch.FieldMap, Sitecore.ContentSearch"> | |
<fieldNames hint="raw:AddFieldByFieldName"> | |
<field fieldName="MyOwnField" 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> | |
</fieldNames> | |
</fieldMap> | |
</myOwnCustomLuceneIndexConfiguration> | |
</indexConfigurations> | |
</contentSearch> | |
</sitecore> | |
</configuration> |
If you add the “_uniqueid” also to your config then Lucene can update the entry, and you can get rid of the duplicated entries.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> | |
<sitecore> | |
<contentSearch> | |
<indexConfigurations> | |
<myOwnCustomLuceneIndexConfiguration type="Sitecore.ContentSearch.LuceneProvider.LuceneIndexConfiguration, Sitecore.ContentSearch.LuceneProvider"> | |
<fieldMap type="Sitecore.ContentSearch.FieldMap, Sitecore.ContentSearch"> | |
<fieldNames hint="raw:AddFieldByFieldName"> | |
<field fieldName="MyOwnField" 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> | |
<field fieldName="_uniqueid" 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> | |
</fieldNames> | |
</fieldMap> | |
</myOwnCustomLuceneIndexConfiguration> | |
</indexConfigurations> | |
</contentSearch> | |
</sitecore> | |
</configuration> |