Example #1
0
 public MergeProcessor()
 {
     TitleIndexList               = new BulkTitleIndex();
     ElasticTitleIndexList        = new BulkElasticTitleIndex();
     ElasticSuggestiveIndexList   = new BulkElasticSuggestiveIndex();
     ElasticOwnershipIndexList    = new BulkElasticOwnershipIndexCollection();
     BulkElasticGroupedTitleIndex = new BulkElasticGroupedTitleIndex();
 }
        public BulkElasticOwnershipIndexCollection Post(BulkElasticOwnershipIndexCollection t)
        {
            int batchCount = 400;

            ConsoleProcess.Start(t.GetType());
            CreateMapping();
            Console.WriteLine(@"Ownership titles count = " + t.ElasticOwnershipCollections.Count);
            var i = 0;

            foreach (var elasticTitle in t.ElasticOwnershipCollections.Batch(batchCount))
            {
                i++;
                ConsoleProcess.Restart();
                var rootDescriptor = GenerateElasticDescriptor(elasticTitle);
                ElasticSearch.Client.Bulk(rootDescriptor);
                Console.WriteLine(Environment.NewLine);
                Console.WriteLine(@"iteration for {0} took - {1} ms", i * batchCount, ConsoleProcess.ElapsedMilliseconds());
            }

            //Parallel.ForEach(t.ElasticOwnershipCollections.Batch(batchCount), elastictitle =>
            //{
            //    i++;
            //    ConsoleProcess.Restart();
            //    var rootDescriptor = GenerateElasticDescriptor(elastictitle);
            //    ElasticSearch.Client.Bulk(rootDescriptor);
            //    if (i % 1000 != 0) return;
            //    Console.WriteLine(Environment.NewLine);
            //    Console.WriteLine(@"iteration for {0} took - {1} ms", i * batchCount, ConsoleProcess.ElapsedMilliseconds());
            //});

            //foreach (var ownershipList in t.ElasticOwnershipCollections)
            //{
            //    ConsoleProcess.Increment();
            //    if (ownershipList.ElasticOwnership.Count > 0)
            //    {
            //        ElasticSearch.BulkIndex(ownershipList.ElasticOwnership, ownershipList.Isbn);
            //    }

            //    ConsoleProcess.ModOf5000();
            //}
            //ElasticSearch.Client.UpdateIndexSettings(us => us.RefreshInterval("1s"));
            ConsoleProcess.End(t.GetType());
            return(t);
        }
Example #3
0
 public MergeOwnershipProcessor()
 {
     ElasticOwnershipIndexList = new BulkElasticOwnershipIndexCollection();
 }