Default projections can't be customized for Unified search

Vote:
 

Hi,

We've faced with issue that we can't use projections functionality from EPiServer Find.

We tried several different solutions but they don't work. 

So we can't change Unified search behaviour without adding changes to ArticlePage.

We hope someone already faced with this and can help us

Solution 1:

[InitializableModule]
[ModuleDependency(typeof (EPiServer.Web.InitializationModule))]
public class SearchInitialization : IInitializableModule
{
    public void Initialize(InitializationEngine context)
    {
        SearchClient.Instance.Conventions
            .ForInstancesOf()
            .ExcludeField(p => p.Title)
            .IncludeField(p => p.SearchTitle());
    }
}
    public static class ArticlePageExtension
    {
        public static string SearchTitle(this ArticlePage page)
        {
            return page.Title;
        }
    }



Solution 2:

            SearchClient.Instance.Conventions.UnifiedSearchRegistry
                .ForInstanceOf()
                .CustomizeIndexProjection(
                    x => x.ProjectTitleFrom(
                        p => p.SearchTitle()));

Solution 3:

            SearchClient.Instance.Conventions.UnifiedSearchRegistry
                .ForInstanceOf()
                .ProjectTitleFrom(p => p.SearchTitle());

Solution 4:

            SearchClient.Instance.Conventions.UnifiedSearchRegistry
                .Add()
                .ProjectTitleFrom(p => p.Title);

P.S. EPiServer Find version is 9.6.0.3185

Best regards,

Pavel

#141895
Nov 24, 2015 10:17
Vote:
 

Solution 4 is not needed since pages and blocks are by default searchable using unified search.

The way to do it is using a Initializable module (as you have in solution 1) and then use conventions to customize the projection.

If I wanted Title to be projected from a "custom field" I would create an extension method "CustomTitle()" and the add the following inside the module:

SearchClient.Instance.Conventions.UnifiedSearchRegistry
                .ForInstanceOf<ArticlePage>()
                .ProjectTitleFrom(x => x.CustomTitle());
#141910
Nov 24, 2015 13:27
Vote:
 

We used Initializable module in all solutions. We've tried your code also and it doesn't work.

I think we have some issue that breaks this code but we don't know where we should look for.

#141913
Nov 24, 2015 14:06
Vote:
 

Ok, I see. If you use the explore view to look at the index, can you see that your extension field is there? What about SearchTitle property?

#141917
Nov 24, 2015 14:30
Vote:
 

SearchTitle property presents in the index but has default value (Page name). ProjectTitleFrom doesn't change default value to custom.

As the result I boosting functionality will not work properly.

If I use ProjectImageUriFrom function ImageUri property will not appears in the index

#141933
Nov 24, 2015 15:58
Vote:
 

Any news on this one? 


I have the same problem and tried all of the 4 solutions above and some more workarounds, but nothing works.

I'm trying to change the projected TypeName and nothing happens, it still remains default in the index. 

This is where I am at right now, but it does not change the projection. :

SearchClient.Instance.Conventions.UnifiedSearchRegistry.ForInstanceOf<StandardPage>().ProjectTypeNameFrom(x => x.CustomSearchTypeName());

Where the CustomSearchTypeName just returns a custom string.

#143601
Edited, Jan 27, 2016 14:03
Vote:
 

Hi,

We added implementation to ArticlePage. We haven't found another solution.

ArticlePage property:

        [Ignore]
        [CultureSpecific]
        [ScaffoldColumn(false)]
        public virtual string SearchTitle { get { return this.SearchTitle(); } }

You can use any properties from ISearchContent

 http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Find/11/DotNET-Client-API/Searching/Unified-search/

#143622
Jan 28, 2016 6:40
Vote:
 

I just ran into the same issue. It's very dissapointing to see this still hasn't been fixed. Just an example of a projection I'm trying to implement:

            SearchClient.Instance.Conventions.UnifiedSearchRegistry
                .ForInstanceOf<MediaData>()
                .ProjectTitleFrom(x => string.Format("{0} [{1}]",x.SearchTitle(), x.SearchFileExtension()));

I could add SearchTitle to my custom Media Model as Pavel has suggested but then I won't have access to the file extension property.

#174833
Feb 06, 2017 13:52
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.