联系我们

Check your content for indexing errors

Senior Developer
Valtech Netherlands

九月 13, 2018

Sometimes you can get errors when indexing your content with Optimizely Find. Most of the time the errors that are logged are quite cryptic. So I have created a validator that uses your Optimizely 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 (https://gist.github.com/jstemerdink/d7553deefb4cae809bd4b47bcec0a673)

 

Update: Also have a look at Brian’s post (https://www.brianweet.com/2019/03/29/find-serialization-exceptions.html)

 

Article originally published on Optimizely Development Blog: Check your content for indexing errors 

联系我们

我們很樂意聽到您的聲音!請填寫表格,辦公室最近的人員將與您聯繫。
如果您需要其他格式和/或溝通支援來提供回饋,請聯絡Sheree Atcheson

让我们重新创造未来