Copied to clipboard

Flag this post as spam?

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


  • Rasmus Eeg 91 posts 457 karma points c-trib
    Nov 10, 2015 @ 13:45
    Rasmus Eeg
    0

    Custom Examine DataService, auto indexing

    Hello there :-)

    Perhaps you can help me?

    I've created a custom:

    ISimpleDataService

        public class AddressDataService : ISimpleDataService
        {
            public IEnumerable<SimpleDataSet> GetAllData(string indexType)
            {
                var watch = new Stopwatch();
                watch.Start();
    
                var dataSetList = new List<SimpleDataSet>();
    
                var workplaces = Builder<Address>
                    .CreateListOfSize(14000)
                    .Random(3)
                    .With(x=>x.MemberNumber = 1)
                    .Build();
    
                foreach (Address workplace in workplaces)
                {
                    var rowData = new Dictionary<string, string> {
                        { "Id", workplace.Id.ToString() },
                        { "Name", workplace.Name },
                        { "Street", workplace.Street },
                        { "ZipCode", workplace.ZipCode.ToString() },
                        { "City", workplace.City },
                        { "PhoneNumber", workplace.PhoneNumber },
                        { "CellPhoneNumber", workplace.CellPhoneNumber },
                        { "Email", workplace.Email }
                    };
    
                    var dataSet = new SimpleDataSet
                    {
                        NodeDefinition = new Examine.IndexedNode
                        {
                            NodeId = workplace.Id,
                            Type = "Workplace"
                        },
                        RowData = rowData
                    };
    
                    dataSetList.Add(dataSet);
                }
                watch.Stop();
                LogHelper.Info<AddressDataService>("{0} addresses was indexed in {1} ms. ", () => workplaces.Count(), () => watch.Elapsed.Milliseconds);
    
                return dataSetList;
            }
        }
    

    And added it to: ExamineIndex.config:

    <IndexSet SetName="AddressIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/{machinename}/AddressIndex/">
        <IndexUserFields>
          <add Name="Id" />
          <add Name="Name" />
          <add Name="Street" />
          <add Name="ZipCode" />
          <add Name="City" />
          <add Name="PhoneNumber" />
          <add Name="CellPhoneNumber" />
          <add Name="Email" />
        </IndexUserFields>
      </IndexSet> 
    

    And to: ExamineSettings.config

     <add name="AddressIndexer" 
            type="Examine.LuceneEngine.Providers.SimpleDataIndexer, Examine"
            dataService="ProjectName.Web.DataService.AddressDataService, Fodterapeuter.Web"
            indexTypes="Workplace"
            indexSet="AddressIndexSet"
            runAsync="false"
            enableDefaultEventHandler="false"/>
    

    Now here is the real problem: Rebuilds every time i restart AppPool I dont wan't that, because i'm indexing 14000 addresses each time.

    is there a way to stop it from indexing on application start?

  • Mike Chambers 636 posts 1253 karma points c-trib
    Nov 10, 2015 @ 15:04
    Mike Chambers
    1

    might help... lifted from this thread... https://our.umbraco.org/forum/getting-started/installing-umbraco/20999-Disable-Lucene-Examine

    Examine will rebuild the indexes on startup if they don't exist. If you've disabled event handlers they will not be updated with publishing, etc... so they'll just sit there. The rebuilding is a one time thing only since they don't exist during startup. That said, you can disable that too by adding this attribute to your config:

    <Examine RebuildOnAppStart="false">
    
  • Rasmus Eeg 91 posts 457 karma points c-trib
    Nov 10, 2015 @ 15:47
    Rasmus Eeg
    0

    Hi Mike,

    Thanks for your comment,

    Though this doesn't really help much. Since i dont wont to disable rebuild for all.

    I just wan't to disbable it for AddressIndexSet

    I can see in the UmbracoTraceLog that GetAllData(string indexType) get called on every application start, even though the temp files exist.

    Reading through the other post.

    I can see that is it not supposed to be called on application start, if the files exist.. but it is.

  • Mike Chambers 636 posts 1253 karma points c-trib
    Nov 10, 2015 @ 16:15
Please Sign in or register to post replies

Write your reply to:

Draft