Searching for pages based on free-text content of associated MediaData



Is it possible to search (unified search) based on the name of the attached media data?

Nov 01, 2022 11:38

I think this can be easiest achieved if you add a list of attached media files as a new property in the index for all pages.

Something like this, just implement GetNamesOfAllAttachedMedia().

public class InitialiseSearch : IInitializableModule
    public void Initialize(InitializationEngine context)
        SearchClient.Instance.Conventions.ForInstancesOf<MyBasePage>().IncludeField(x => x.GetNamesOfAllAttachedMedia());       
Nov 01, 2022 12:05

Can you please give an example of implementation of GetNamesOfAllAttachedMedia?

Thanks in advance.

Nov 02, 2022 7:27

The implementation would depend on how you plan on attaching media data.

Do you reference the media data from one specific property? Or multiple properties?
What property types would be used to reference the media?

Nov 02, 2022 9:12

I am using a Content area where I have a custom block from where I add Files. Here is my files block

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

The quickest solution would be adding the [IndexInContentAreas] atttribute to DocumentListBlock and GenericMedia/ImageFile, like described here:

You could then use the [Find] > [Overview] > [Explore] feature in the Optimizely UI to check that the filenames are actually indexed as part of the page.

So, just forget my previous suggestion :-)

Edited, Nov 02, 2022 10:02
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.