1

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?

2
  • 2
    You can do this with a computed field. Aug 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! Aug 7, 2018 at 15:15

1 Answer 1

5

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.