Try our conversational search powered by Generative AI!

Loading...
Area: Optimizely Search & Navigation
ARCHIVED This content is retired and no longer maintained. See the latest version here.

Recommended reading 

In most situations where the content that is to be indexed contains HTML tags, we want to remove the tags before indexing as we otherwise will both search in HTML tags and have HTML markup returned in search results.

Examples

Example of removing HTML tags from a specific RemoveHtmlTagsWhenIndexing attribute found in the EPiServer.Find.Json namespace:

C#
using EPiServer.Find.Json;

public class WithStringProperty
{
    public string Title { get; set; }

    [RemoveHtmlTagsWhenIndexing]
    public string Content { get; set; }
}

It is also possible to customize the Client conventions to remove HTML tags from all string fields:

C#
client.Conventions.ForInstancesOf<object>()
    .FieldsOfType<string>().StripHtml();

To remove HTML tags from a specific field when indexing a specific type, we can use the ForType and Field methods:

C#
client.Conventions.ForType<BlogPost>()
    .Field(x => x.Content).StripHtml();
Do you find this information helpful? Please log in to provide feedback.

Last updated: Sep 26, 2013

Recommended reading