I think there are two approaches you could take.
One is to add a custom field in the Examine index and then using the GatheringNodeData
event, index the text that you want to display. That way you will be able to access it from the SearchResult object (@result.Fields["customFieldName"]
). The GatheringNodeData
event handler will have to parse the grid data to extract the text snippet you want and then add it to the Examine document (e.Fields["content"] = textSnippet
).
The other approach would be to get the text snippet from the node when displaying the results.
var helper = new UmbracoHelper(UmbracoContext.Current);
foreach (var result in results)
{
var node = helper.TypedContent(result.Id);
var gridData = node.GetPropertyValue("contentgrid");
// some code for extracting the text snippet from the grid data
}
Note in both techniques, you need to figure out how to extract the text snippet you want from the grid data. You could use Skybrud.Umbraco.GridData or just parse the JSON yourself (using JSON.NET). I think the post @Harvey mentioned in a comment yesterday would be helpful for this (and more details on handling the GatheringNodeData
event).