No highlighting of HTML content?

Vote:
 

Hi,

Is highlighting with AsHighlighted not supported on indexed content that contains HTML tags? I am getting a search hit on the content document, but the value returned from AsHighlighted is empty. If I index the field without HTML tags, the highlighting works. (I am not using unified search, I'm using typed search.)

Update: some times I get a highlighted result back, but the marking tags interfere with the HTML tags. 

#202197
Mar 19, 2019 11:26
Vote:
 

Hi, Johan

Have you checked that your initialization of Find returns proper highlighting syntax as specified in the documentation?https://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Find/9/DotNET-Client-API/Searching/Highlightning/

I don't think there should be an issue with having a mix of html content for the indexed entries but perhaps you have not set the custom css styles for highlighting the content in your project's stylesheets?

#202241
Mar 20, 2019 15:53
Vote:
 

Hi,

Vi sågs bestämt på en lunch bredvid Consid för inte länge sen ;)

I've setup highlighting and I'm creating my projection as follows but the problem is the resulting <mark> sections seem to not heed the structure of the HTML tags:

var highlightSpec = new HighlightSpec()
{
    NumberOfFragments = 1,
    FragmentSize = 200,
    PreTag = "<mark>",
    PostTag = "</mark>",
};
var projection = search.Select(x => new
{
   ContentLink = x.ContentLink,
   HighlightedTitle = x.SearchTitle().AsHighlighted(highlightSpec),
   HighlightedContent = x.MyHtmlProp.AsHighlighted(highlightSpec)
})
.StaticallyCacheFor(TimeSpan.FromMinutes(1))
.GetResult();

The result when the marked phrase is overlapping HTML is for example:

<ul>
    <li>Lorem ipsum <mark>dolor</li>
    <li>sit amet</mark> consectetur adipiscing elit</li>
</ul>
#202385
Edited, Mar 25, 2019 12:18
Vote:
 

Det stämmer ju bra :)

Check if the Pre/PostTagForAllHighlights works out better for you:

public UnifiedSearchResults Search(string query)
        {
            var querySearch = _client.UnifiedSearchFor(query);
 
            var hitSpecification = new HitSpecification
            {
                PreTagForAllHighlights = "<em class='highlight--text'>",
                PostTagForAllHighlights = "</em>",
                HighlightTitle = true,
                HighlightExcerpt = true
            };
 
            var currentCulture = ContentLanguage.PreferredCulture;
 
            return querySearch.OverrideCurrentLanguage(currentCulture.Name).Track().ApplyBestBets().GetResult(hitSpecification);
        }
#202651
Edited, Mar 28, 2019 13:03
Vote:
 

Thanks but we're using typed search and not unified search. I've since solved it by just extracting the highlight fragments and delegating the actual highlighting to the client instead.

#202655
Mar 28, 2019 14:32
* 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.