Exemple #1
0
        public async Task Write(IndexingJob job)
        {
            try
            {
                var timer = new Stopwatch();
                timer.Start();

                var docCount = 0;

                foreach (var doc in job.Documents)
                {
                    docCount++;

                    await Write(doc);
                }

                _log.Log(string.Format("build in-memory index from {0} docs in {1}", docCount, timer.Elapsed));

                await Serialize();

                var collectionId = CollectionId.ToHash();

                foreach (var index in _dirty)
                {
                    SessionFactory.Publish(collectionId, index.Key, index.Value);
                }

                _log.Log(string.Format("indexed {0} docs in {1}", docCount, timer.Elapsed));
            }
            catch (Exception ex)
            {
                _log.Log(ex);

                throw;
            }
        }