Created
January 28, 2013 16:42
-
-
Save tomfulton/4657070 to your computer and use it in GitHub Desktop.
Example of Examine GatheringNodeData event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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