Get related hits on attached documents for pages in Episerver

Vote:
 

I have a page type which is called InfoPage and the code is like this for that

public class InfoPage : StandardPage
    {

        [Display(GroupName = SystemTabNames.Content, Order = 300)]
        [CultureSpecific]
        public virtual ContentArea RightSideArea { get; set; }

        [Display(GroupName = SystemTabNames.Content, Order = 350)]
        [CultureSpecific]
        public virtual string RightSideBoxHeader { get; set; }
        
    }

Now in the rightSideArea users can add blocks and one of the block type is this

    public class DocumentListBlock : SiteBlockData
    {
        [Display(GroupName = SystemTabNames.Content, Order = 100)]
        [AllowedTypes(new[] { typeof(GenericMedia) })]
        public virtual ContentArea Files { get; set; }
    }

Now what I am trying to do is when I doing search (unified search) I want to check if the page has any documents in that rightSideArea whose name contains "X". 

I started following this article https://ericceric.com/2020/04/17/get-related-hits-on-attached-documents-for-pages-in-episerver-search-and-navigation/ to add a SearchAttachmentText but it doesn't seem to work.

I have installled this package

EPiServer.Find.Cms.AttachmentFilter

Then I added this in dependencyRessolver

c.For<IAttachmentHelper>().Use<DefaultAttachmentHelper>();

Then in my FindInitialization I did this

            var searchConventions = SearchClient.Instance.Conventions;

            searchConventions.ForInstancesOf<InfoPage>()
                .IncludeField(x => x.SearchAttachmentText());

And then I created an extension function like this

public static string SearchAttachmentText(this InfoPage page)

{
   // here I want to find the documents from the content area but for now I am returing a dummy text to see if it indexes

return "test";

}

But it doesn't help. When I create a new InfoPage it doesn't add this in index.

#290983
Nov 02, 2022 12:26
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.