Try our conversational search powered by Generative AI!

Getting wrong data with UnifiedSearch

Vote:
 

I'm using CMS 6 r2 with UnifiedSearch. I've declared the property SearchSummary in my basepage (PageType Builder 2.0).

 

public string SearchSummary
{
get
{
var propertyMainIntro = this.Property.ExistsLocally("MainIntro") && this["MainIntro"] != null ? this["MainIntro"].ToString() : String.Empty;
if (!String.IsNullOrWhiteSpace(propertyMainIntro))
{
return propertyMainIntro;
}
return String.Empty;
}
}

 

In some cases the Excerpt field on the UnifiedSearchHit object only gives me the MainIntro field, which is correct. For some of the other pages I get both the MainIntro and MainBody field. Both pagetypes inherit the basepage. There are no differences for the two page types in my indexing convention.

Any tips?

#68351
Mar 20, 2013 14:51
Vote:
 

Seems that when the MainIntro field is populated with html tags, both these tags and MainBody is retrieved. Why is MainBody retrieved at all? Is it a default "fallback property"?

#68352
Mar 20, 2013 15:00
Vote:
 

Hi,

By "default" all properties marked as Searchable in the page definition is included in SearchText that in turn is a "fallback" property. If you only want SearchSummary in the Excerpt you can override the defult Excerpt projection by:

client.Conventions.UnifiedSearchRegistry.ForInstanceOf<MyBasePageType>()
.ProjectExcerptUsing<ISearchContent>(spec =>
x => x.SearchText.AsCropped(spec.ExcerptLength));

If you are using Highlighting you have to override the HighlightExcerpt by:

client.Conventions.UnifiedSearchRegistry.ForInstanceOf<MyBasePageType>()
.ProjectHighlightedExcerptUsing<ISearchContent>(spec =>
x => x.SearchSummary.AsHighlighted(
new HighlightSpec { FragmentSize = spec.ExcerptLength, NumberOfFragments = 1 }));

Regards,
Henrik

#68360
Mar 20, 2013 15:44
Vote:
 

How would this work with the singleton?

I don't get intelliSense for the .ProjectExcerptUsing method in my indexing convention class.

#68363
Mar 20, 2013 16:17
Vote:
 

Swap client to SearchClient.Instance and add EPiServer.Find.UnifiedSearch to your usings.

#68364
Mar 20, 2013 16:50
Vote:
 

I first tried this without any luck:

SearchClient.Instance.Conventions.UnifiedSearchRegistry.ForInstanceOf<PageType_BasePage>()
.ProjectHighlightedExcerptUsing<ISearchContent>(spec => x => x.SearchSummary.AsHighlighted(new HighlightSpec { FragmentSize = spec.ExcerptLength, NumberOfFragments = 1 }));

Here is the result from the search on a specifici test article, using the code above. Properties in order are title, heading, intro, body. As you can see the intro is just an empty <strong> tag. As soon as I populate the tag with something, the intro alone is returned in the result.

Testartikkel Testartikkel <strong></strong> Brødtekst                         

 

Since I haven't actually implement ISearchContent but rather declared the properties with the same name and type I tried the following, also without any luck:

SearchClient.Instance.Conventions.UnifiedSearchRegistry.ForInstanceOf<PageType_BasePage>()
.ProjectHighlightedExcerptUsing<PageType_BasePage>(spec => x => x.SearchSummary.AsHighlighted(new HighlightSpec { FragmentSize = spec.ExcerptLength, NumberOfFragments = 1 }));

 

This is not really a big showstopper though, as I can just filter out the html tags before displaying the result.

#68383
Edited, Mar 21, 2013 10:27
Vote:
 

As you have edited Highlighting excerpts are you passing the HitsSpecification to GetResult?

.GetResult(new HitSpecification { HighlightExcerpt = true })

and that you are using the .For(querystring) so that it has something to highlight on?

#68388
Mar 21, 2013 11:59
Vote:
 

No, I hadn't passed the HitsSpec, but I've done so now and it looks like it works.

Thanks :)

#68391
Mar 21, 2013 12:49
Vote:
 
#69118
Mar 22, 2013 10:01
* 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.