public void Indexer_AfterReIndex(object sender, uSearch.Businesslogic.ReIndexEventArgs e) { Businesslogic.Indexer i = (Businesslogic.Indexer)sender; Lucene.Net.Index.IndexWriter iw = i.ContentIndex(false); umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, "Re-indexing projects"); try { int projectRoot = 1113; XPathNodeIterator pages = umbraco.library.GetXmlNodeById(projectRoot.ToString()).Current.Select(".//node [@nodeTypeAlias = 'Project']"); //umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, pages.Current.OuterXml); while (pages.MoveNext()) { if (pages.Current is IHasXmlNode) { XmlNode node = ((IHasXmlNode)pages.Current).GetNode(); string key = "project_" + node.Attributes["id"].Value; Hashtable fields = new Hashtable(); fields.Add("id", node.Attributes["id"].Value); fields.Add("name", node.Attributes["nodeName"].Value); fields.Add("content", umbraco.library.StripHtml(umbraco.xmlHelper.GetNodeValue(node.SelectSingleNode("data [@alias = 'description']")))); fields.Add("path", (node.Attributes["path"].Value.Replace("-1,", "").Replace(",", i.IndexerSettings.PathSplit))); i.AddToIndex(key, "project", fields, iw); } } } catch (Exception ex) { //umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, ex.ToString()); } umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, "Re-indexing projects - DONE"); iw.Optimize(); iw.Close(); //umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, "Wiki index done"); }
public void Indexer_AfterReIndex(object sender, uSearch.Businesslogic.ReIndexEventArgs e) { Businesslogic.Indexer i = (uSearch.Businesslogic.Indexer)sender; IndexWriter iw = i.ContentIndex(false); umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, "Re-indexing forum posts"); try { List <Forum> forums = uForum.Businesslogic.Forum.Forums(); foreach (Forum f in forums) { try{ foreach (Topic t in Topic.TopicsInForum(f.Id)) { Hashtable fields = new Hashtable(); fields.Add("id", t.Id.ToString()); fields.Add("name", t.Title); fields.Add("author", t.MemberId.ToString()); fields.Add("content", umbraco.library.StripHtml(t.Body)); i.AddToIndex("topic_" + t.Id.ToString(), "forumTopics", fields, iw); } }catch (Exception ex) { umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, ex.ToString()); } } } catch (Exception ex) { umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, ex.ToString()); } umbraco.BusinessLogic.Log.Add(umbraco.BusinessLogic.LogTypes.Debug, -1, "Re-indexing forum posts - DONE"); iw.Optimize(); iw.Close(); }