Skip to content

Instantly share code, notes, and snippets.

@tomfulton
Created January 28, 2013 16:42
Show Gist options
  • Save tomfulton/4657070 to your computer and use it in GitHub Desktop.
Save tomfulton/4657070 to your computer and use it in GitHub Desktop.
Example of Examine GatheringNodeData event
void Search_GatheringNodeData(object sender, IndexingNodeDataEventArgs e)
{
// Create the "munged" field
AddToContentsField(e);
// Add a dummy value so its easy to get all docs
e.Fields.Add("allDocs", "1");
// Replace CSV strings with spaces - easier to search
if (e.Fields.ContainsKey("searchChannels"))
{
e.Fields.Add("searchChannelsSpaced", string.Concat(" ," + e.Fields["searchChannels"].Replace(",", ", ,"), ", "));
}
// Add the ID field
e.Fields.Add("articleId", Helpers.GetResourceId(e.NodeId));
}
private void AddToContentsField(IndexingNodeDataEventArgs e)
{
Dictionary<string, string> fields = e.Fields;
var combinedFields = new StringBuilder();
foreach (KeyValuePair<string, string> keyValuePair in fields)
{
combinedFields.AppendLine(keyValuePair.Value.ToLower());
}
e.Fields.Add("mungedContents", combinedFields.ToString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment