Copied to clipboard

Flag this post as spam?

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


  • Shada 55 posts 137 karma points
    Feb 04, 2016 @ 10:20
    Shada
    0

    custom Examine index very slow

    When I rebuild the index I wait about 15 minutes. Although when I connect to w3wp in debug mode, I see that GetAllData work out for about 7 seconds.

    Why build indexes takes so long? Is it possible to speed up?

    I add in my ExamineIndex.config:

      <IndexSet SetName="OrganizationsIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/OrganizationsIndexSet/" >
        <IndexUserFields>
          <add Name="Id"/>
          <add Name="Url"/>
          <add Name="Category"/>
        </IndexUserFields>
      </IndexSet>
    

    ExamineSettings.config:

        <Examine>
          <ExamineIndexProviders>
            <providers>
              <add name="InternalIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"
                   supportUnpublished="true"
                   supportProtected="true"
                   analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net"/>
    
              <add name="InternalMemberIndexer" type="UmbracoExamine.UmbracoMemberIndexer, UmbracoExamine"
                   supportUnpublished="true"
                   supportProtected="true"
                   analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"/>   
    
                <add name="ExternalIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"/>                   
    
              <add name="OrganizationsIndexer"
                   type="Examine.LuceneEngine.Providers.SimpleDataIndexer, Examine"
                   dataService="Podoroznik.OrganizationsDataService, Podoroznik"
                   indexSet="OrganizationsIndexSet" 
                   analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"
                   indexTypes="CustomData"
                   runAsync="false"/>
            </providers>
          </ExamineIndexProviders>
    
          <ExamineSearchProviders defaultProvider="ExternalSearcher">
            <providers>
              <add name="InternalSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
                   analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net"/>
    
              <add name="ExternalSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine" />
    
              <add name="InternalMemberSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
                   analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" enableLeadingWildcard="true"/>
    
              <add name="OrganizationsSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine" analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"/>
            </providers>
          </ExamineSearchProviders>
    
        </Examine>
    

    And my OrganizationsDataService.cs:

    using System.Collections.Generic;
    using System.Linq;
    using Examine;
    using Examine.LuceneEngine;
    using Umbraco.Core.Models;
    using Umbraco.Web;
    
    namespace Podoroznik
    {
    
        public class OrganizationsDataService : ISimpleDataService
    
        {
            public IEnumerable<SimpleDataSet> GetAllData(string indexType)
    
            {
                var helper = new UmbracoHelper(UmbracoContext.Current);
                var data = new List<SimpleDataSet>();
    
                foreach (var content in helper.TypedContent(1127).Descendants("Organization").Where("Visible"))
                {
                    Organization organization = new Organization() { Id = content.Id, Url = content.Url };
                    IPublishedContent categoriesNode = content.Children.FirstOrDefault(z => z.DocumentTypeAlias == "categoriesNode");
    
                    if (categoriesNode != null)
                    {
                        foreach (var x in categoriesNode.Children())
                        {
                            organization.Category = x.GetPropertyValue<string>("category");
                            AddOrganization(data, organization);
                        }
                    }
                    else
                    {
                        AddOrganization(data, organization);
                    }
    
                }
                return data;
            }
            public class Organization
            {
                public int Id { get; set; }
                public string Url { get; set; }
                public string Category { get; set; }
            }
    
            private void AddOrganization(List<SimpleDataSet> data, Organization item)
            {
                data.Add(new SimpleDataSet()
                {
                    NodeDefinition = new IndexedNode()
                    {
                        NodeId = item.Id, Type = "CustomData"
                    },
    
                    RowData = new Dictionary<string, string>()
                        {
                            {"id", item.Id.ToString()},
                            {"url", item.Url},
                            {"category", item.Category}
                        }
                });
            }
        }
    }
    

    Umbraco 7.2.6

Please Sign in or register to post replies

Write your reply to:

Draft