Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

TermsFacetFor use for Webcontent

Vote:
 

We are using Episerver find to index our site (using our own type ISearchableContent) along with an external connector to crawl another site for new articles.

We then use TermsFacetFor to build a list of types that we use as filters available in our search result screen.

// Code Shortened for example
var search = searchClient.UnifiedSearch(Language.English);
search = search.TermsFacetFor(x => x.SearchSection);
search = search.Filter(x => x.MatchTypeHierarchy(typeof(ISearchableContent)) | x.MatchType(typeof(WebContent)));

var unifiedResults = search.GetResult(new HitSpecification { HighlightExcerpt = true, EncodeExcerpt = false }, searchDefinition.FilterForVisitor);
var contentLabelFacets = unifiedResults.TermsFacetFor(x => x.SearchSection);

The issue we have is the WebCotent doesnt appear to implement all of the properties of ISearchContent, namely SearchSection which we are using for our Facets.

Any idea how we use could specify a common field for facets in both types of content? All of the fields in WebContent seem unsuitable.

Couple of Ideas I had were
- somehow force all the WebContent to have a set value for SearchSection?
- maybe use SearchSourceName in WebContent and add that to ISearchableContent but that would require the index to have a specific name which doesnt seem ideal.

Ben

#155423
Edited, Sep 16, 2016 12:58
Vote:
 

You can add a SearchSection() extension method for WebContent.

"By having a property or extension method with the same name and type as a property in the interface, the property is treated as if it were received from the interface."
http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Find/9/DotNET-Client-API/Searching/Unified-search/

#155462
Edited, Sep 18, 2016 18:06
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.