Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

Unified Search Index Projection Not Working at all

Vote:
 

Hi, I am trying to customize the index projection for unified search like below

SearchClient.Instance.Conventions.UnifiedSearchRegistry
              .ForInstanceOf().ProjectTitleFrom(s => s.Position);

But i have noticed after several days of debugging that below code in EPiServer.Find.Cms.CmsClientConventions

client.Conventions.ForInstancesOf().IncludeField((Expression>) (x => x.ContentLink)).IncludeField((Expression>) (x => x.GetTimestamp())).IncludeField((Expression>) (x => x.SiteId())).IncludeField((Expression>) (x => x.ContentTypeName())).IncludeField((Expression>) (x => x.Ancestors())).IncludeField>((Expression>>) (x => x.PublishedInLanguage())).IncludeField((Expression>) (x => x.CommonName())).IncludeField((Expression>) (x => x.CommonType())).IncludeField((Expression>) (x => x.CommonTypeShortName())).IncludeField((Expression>) (x => x.CommonTypeDisplayName())).IncludeField((Expression>) (x => x.SearchTitle())).IncludeField((Expression>) (x => x.SearchText())).IncludeField((Expression>) (x => x.SearchSection())).IncludeField((Expression>) (x => x.SearchSubsection())).IncludeField((Expression>) (x => x.HasTemplate())).IdIs((Func) (x => (DocumentId) x.GetIndexId())).ExcludeField("__interceptors").ExcludeFieldMatching((Func) (prop => typeof (XForm).IsAssignableFrom(prop.PropertyType))).ExcludeFieldMatching((Func) (prop => typeof (PageType).IsAssignableFrom(prop.PropertyType))).ExcludeFieldMatching((Func) (prop => typeof (Url).IsAssignableFrom(prop.PropertyType))).ExcludeFieldMatching((Func) (prop => typeof (LinkItemCollection).IsAssignableFrom(prop.PropertyType)));

always takes the precedence. I think the only way to override the SearchTitle/SearchSection is to provide the extension method not through the unified registry?

Any comments regarding this?

#190346
Edited, Apr 10, 2018 2:12
Vote:
 

It's easier if you reuse one of the property names of ISearchContent:
https://world.episerver.com/documentation/class-library/?documentId=find/8/15648C26

If I understand your question you could just add a SearchTitle property that returns this.Position.

Then you can also inspect the index and see what's there.

#190673
Apr 14, 2018 23:22
Vote:
 

Hi Johan,

I am doing following way 

First I am removing existing field which was added in EPiServer.Find.Cms.CmsClientConventions

  SearchClient.Instance.Conventions.ForInstancesOf<IContent>()
                .ExcludeField(p => p.SearchSection());

and then I have added my own function as extension method for individual class

  public static string SearchSection(this PlayerPage content)
        {
            return content.Position;
        }

and then added in unified registry

  SearchClient.Instance.Conventions.ForInstancesOf<PlayerPage>()
                .IncludeField(p => p.SearchSection());



but the questions is if the below feature does not work then why it is ther?

SearchClient.Instance.Conventions.UnifiedSearchRegistry
              .ForInstanceOf().ProjectTitleFrom(s => s.Position);
#190680
Apr 16, 2018 3:06
* 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.