Check your content for indexing errors

Sometimes you can get errors when indexing your content with Episerver Find. Most of the time the errors that are logged are quite cryptic.

So I have created a validator that uses your Episerver Find instance to check if your content will cause problems when it’s being indexed.

You just need to get the Serializer from the SearchClient,  get your custom conventions and serialize the content.

JsonSerializer jsonSerializer = Serializer.CreateDefault();
Action customizeSerializer
= SearchClient.Instance.CustomizeSerializer;
customizeSerializer(obj: jsonSerializer);

IClientConventions defaultConventions = SearchClient.Instance.Conventions;

if (defaultConventions.ContractResolver.IsNotNull())
{
	jsonSerializer.ContractResolver = defaultConventions.ContractResolver;
}

if (defaultConventions.CustomizeSerializer.IsNotNull())
{
	defaultConventions.CustomizeSerializer(obj: jsonSerializer);
}

jsonSerializer.Serialize(value: content);

If there are any serialization errors you can return a warning, an error, whatever you prefer

You can get the complete validator in this gist

Update: Also have a look at Brian’s post

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s