private void UpdateCommitMetadata(DateTime commitTimeStamp, int docsDifference)
        {
            var count = docsDifference;

            if (_metadataForNextCommit != null)
            {
                // we want the total for the entire commit, so add to the number we already have
                count += _metadataForNextCommit.Count;
            }

            _metadataForNextCommit = DocumentCreator.CreateCommitMetadata(
                commitTimeStamp, "from catalog", count, Guid.NewGuid().ToString());
        }
        protected override async Task <bool> OnProcessBatch(CollectorHttpClient client, IEnumerable <JToken> items, JToken context, DateTime commitTimeStamp, CancellationToken cancellationToken)
        {
            JObject catalogIndex = (_baseAddress != null) ? await client.GetJObjectAsync(Index, cancellationToken) : null;

            IEnumerable <JObject> catalogItems = await FetchCatalogItems(client, items, cancellationToken);

            using (IndexWriter indexWriter = CreateIndexWriter(_directory))
            {
                Trace.TraceInformation("Index contains {0} documents", indexWriter.NumDocs());

                ProcessCatalogIndex(indexWriter, catalogIndex, _baseAddress);
                ProcessCatalogItems(indexWriter, catalogItems, _baseAddress);

                indexWriter.ExpungeDeletes();

                indexWriter.Commit(DocumentCreator.CreateCommitMetadata(commitTimeStamp, "from catalog", Guid.NewGuid().ToString()));

                Trace.TraceInformation("COMMIT index contains {0} documents commitTimeStamp {1}", indexWriter.NumDocs(), commitTimeStamp.ToString("O"));
            }

            return(true);
        }