Say I have a template "ArticlePage" which includes the field "ArticleTitle" and then I have another template called "ContentPage" which includes the field "Title". (I know this is not an ideal setup, so try to ignore that fact). Assuming that no two pages inherit both of those templates, is there a way to configure my search indexes so that both those template fields go into the same field in my ContentSearch index?
-
2You can do this with a computed field.– Hishaam NamooyaAug 7, 2018 at 15:00
-
Of course! And the computed field would obviously just reference the two different template field IDs as necessary. Thank you! Feel free to add that as an answer for some upvotes!– Matthew DresserAug 7, 2018 at 15:15
1 Answer
You can use a computed field to make both fields to point to a single field in the index.
public override object ComputeFieldValue(IIndexable indexable)
{
Item currentItem = indexable as SitecoreIndexableItem;
// Your logic goes here
}
Then add it to the AddComputedIndexField
<field fieldName="YourComputedFieldName" returnType="string">YourNamespace, Your assembly</field>