Created
November 13, 2013 22:16
-
-
Save gravypower/7457477 to your computer and use it in GitHub Desktop.
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
protected override void OnDocumentWriting(DocumentWritingEventArgs docArgs) | |
{ | |
var currentNode = _nodeFactoryFacade.GetNode(docArgs.NodeId); | |
var categories = currentNode.GetProperty("categories").Value; | |
if (!string.IsNullOrEmpty(categories)) | |
{ | |
var categoryNodeIdsXml = XElement.Parse(categories); | |
var categoryNodeIds = categoryNodeIdsXml.Descendants("nodeId"); | |
foreach (var categoryNodeId in categoryNodeIds) | |
{ | |
docArgs.Document.Add(new Field("categories", categoryNodeId.Value, Field.Store.YES, Field.Index.ANALYZED)); | |
} | |
} | |
base.OnDocumentWriting(docArgs); | |
} |
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
protected override void OnGatheringNodeData(IndexingNodeDataEventArgs e) | |
{ | |
var currentNode = _nodeFactoryFacade.GetNode(e.NodeId); | |
var categories = e.Node.Descendants("XPathCheckBoxList").Descendants("nodeId"); | |
e.Fields.Add("categories", string.Join("|", categories.Select(x=>x.Value))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment