Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matthew Hunt 13 posts 35 karma points
    Oct 23, 2012 @ 18:30
    Matthew Hunt
    0

    Azure, Examine and GatheringNodeData

    I've got a site up and running on Azure using the Umbraco Accelerator, the site runs fine except my site search. I'm hooking into the GatheringNodeData event and adding a new field programmatically that pulls data from different node types and places all of the searchable text into a common field so I can search on that field.

    The problem seems to be that each time a web role restarts (could be something else causing this, but this seems to make sense) I lose this field in the index and it only seems to repopulate when I do a manual publish of existing items. I've only been using Umbraco for a few months and this is the first large / complex site I've built.

    From looking at the Accelerator code each Web Role has its own index files, I'm also concerned that one may have the correct indexes and the other Web Role not.

    Am i doing something wrong? Does anyone have experience of this or knowledge of what could be going wrong?

    Here's the revelant code:

    private const string SearchTextField = "searchText";

     
    public ExamineEvents()
    {
        ExamineManager.Instance.IndexProviderCollection["GeneralIndexer"].GatheringNodeData += GeneralExamineEvents_GatheringNodeData;
    }
    
    void GeneralExamineEvents_GatheringNodeData(object sender, IndexingNodeDataEventArgs e)
    {
        if (e.Fields.ContainsKey("nodeTypeAlias"))
        {
            string searchText;
            switch (e.Fields["nodeTypeAlias"])
            {
                case "ProductItem":
                    searchText = e.Fields["summary"];
                    if (e.Fields.ContainsKey("features"))
                    {
                        searchText += string.Concat(". ", e.Fields["features"]);
                    }
                    e.Fields.Add(SearchTextField, searchText);
                    break;
                case "NewsArticle":
                    if (e.Fields.ContainsKey("bodyText"))
                    {
                        searchText = e.Fields["bodyText"];
                        e.Fields.Add(SearchTextField, searchText);
                    }
                    break;
                case "DownloadItem":
                    searchText = e.Fields["nodeName"];
                    e.Fields.Add(SearchTextField, searchText);
                    break;
                case "KnowledgeItem":
                    if (e.Fields.ContainsKey("bodyText"))
                    {
                        searchText = e.Fields["bodyText"];
                        e.Fields.Add(SearchTextField, searchText);
                    }
                    break;
            }
        }
    }
    <IndexSet SetName="GeneralIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/General/">
        <IndexAttributeFields>
          <add Name="id" />
          <add Name="nodeName" />
          <add Name="updateDate" />
          <add Name="writerName" />
          <add Name="path" />
          <add Name="nodeTypeAlias" />
          <add Name="parentID" />
        </IndexAttributeFields>
        <IndexUserFields>
        </IndexUserFields>
        <IncludeNodeTypes>
          <add Name="KnowledgeItem" />
          <add Name="ProductItem" />
          <add Name="DownloadItem" />
          <add Name="NewsArticle" />
        </IncludeNodeTypes>
    
        <ExcludeNodeTypes />
      </IndexSet>

     

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Nov 28, 2012 @ 11:52
    Jeavon Leopold
    0

    Hi Matthew,

    I am interested to know if you managed to resolve this issue? I have seen this issue myself but I am unsure if it is an Azure specific issue, general load balancing or something else. Also were you using the Azure specific version of Examine or the default one?

    Regards,

    Jeavon

Please Sign in or register to post replies

Write your reply to:

Draft