Try our conversational search powered by Generative AI!

How to use UnifiedSearch for EPiServer CMS 6 R2

Vote:
 

Hi

We are using EPiServer CMS 6 R2.

We would like to use UnifiedSearch in our project.

All the pages in our project are created through CMS mode but not by using page type builder.

I'm not able to use the following code in Global.asax.cs, the error message says EPiServer.Find.IClientConventions does not contain a definition for ForInstanceOf:

SearchClient.Instance.Conventions.ForInstancesOf<PageData>().IncludeField(page => page.SearchText())  

 

Can someone tell me how to include page data in order to use UnifiedSearch

Thanks.

#74576
Sep 02, 2013 11:15
Vote:
 

Try SearchClient.Instance.UnifiedSearchFor(query)

#74577
Sep 02, 2013 11:23
Vote:
 

Hi Andreas,

I tried the following but no results retrieved in any trial:

var results = client.UnifiedSearchFor(Query, Language.English).GetResult(new HitSpecification(), false);

            var results1 = SearchClient.Instance
                        .UnifiedSearchFor(Query, Language.GetSupportedLanguage(ContentLanguage.PreferredCulture))
                        .GetResult();

            var results2 = SearchClient.Instance
                        .UnifiedSearchFor(Query, Language.GetSupportedLanguage(ContentLanguage.PreferredCulture))
                        .GetResult(new HitSpecification(), false);
#74579
Sep 02, 2013 11:34
Vote:
 

Can you confirm that your index contains the data you are searching for? (By looking in the index directly using EPiServer admin mode)

#74581
Sep 02, 2013 12:48
Vote:
 

Hi, Following are the Index details:

Index named XXXX contains 130 documents

.NET API version: 1.0.0.278

ImageVaultDoc(55)

ImageVaultNonDoc(5)

PageData(70)

I'm able to fetch the results If I use simple Search like:

ITypeSearch<PageData> query = client.Search<PageData>()
                    .For(Query)
                    .WithAndAsDefaultOperator()

var result = query.Select(x => new SearchHit
                    {
                        PageTitle = x.PageName,
                        Id = x.PageLink.ID,
                        Url = x.LinkURL
                    })
                    .Track()
                    .Take(Count)
                    .GetResult();

    

But We want to use UnifiedSearch.We are using CMS6 R2.

#74583
Edited, Sep 02, 2013 13:07
Vote:
 

Following is the code that I have in global.asax.cs:

PageIndexer.Instance.Conventions.ForInstancesOf<PageData>().ShouldIndex(x => x.Category.IsIndexableCategoryList());

SearchClient.Instance.Conventions.ForInstancesOf<PageData>()
                        .IncludeField(page => page.SearchText())
                        .IncludeField(page => page.LinkURL)
                        .IncludeField(page => page.StartPublish)
                        .IncludeField(page => page.PageTypeName)
                        .IncludeField(page => page.StopPublish)
                        .IncludeField(page => page.PageName);

And following is the code in ascx.cs file :

var results1 = SearchClient.Instance
                        .UnifiedSearchFor(Query, Language.GetSupportedLanguage(ContentLanguage.PreferredCulture))
                        .GetResult();

var results2 = SearchClient.Instance
                        .UnifiedSearchFor(Query, Language.GetSupportedLanguage(ContentLanguage.PreferredCulture))
                        .GetResult(new HitSpecification(), false);

Please suggest ur Ideas If anything I'm missing.

Thanks

#74584
Sep 02, 2013 13:13
Vote:
 

I had similar wunder story :)

 http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=74013&epslanguage=en

Bottom line for my case was that UnifiedSearch *started* to yield results without any changes either in code or in index content.

#74586
Edited, Sep 02, 2013 13:23
Vote:
 

Hi All,

I'm able to see my search query is giving the some result count with the following code:

In Global.asax.cs File I have:

SearchClient.Instance.Conventions.ForInstancesOf<PageData>()
                        .IncludeField(page => page.SearchText())
                        .IncludeField(page => page.LinkURL)
                        .IncludeField(page => page.StartPublish)
                        .IncludeField(page => page.PageTypeName)
                        .IncludeField(page => page.StopPublish)
                        .IncludeField(page => page.PageName);

And in ascx.cs :

SearchClient.Instance.Conventions.UnifiedSearchRegistry.Add<PageData>();

var results = SearchClient.Instance
                        .UnifiedSearchFor(Query, Language.GetSupportedLanguage(ContentLanguage.PreferredCulture))
                        .GetResult(new HitSpecification(), false);

foreach (EPiServer.Find.UnifiedSearch.UnifiedSearchHit hit in results)
 {
   litUnifiedSearch.Text += hit.Filename;
 }

While debugging I can see other than Excerpt nothing is giving any data about the search hit.

I want to retrieve the properties of Pages like Start Publish, Page Name, LinkUrl,etc.

Any Idea will be a greate help for me.

Thanks

#74624
Sep 03, 2013 9:09
* 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.