public async Task FilterLogsWithCriteria()
        {
            const string INDEX_NAME = "filter-logs-with-criteria";

            //surround with "using" so that anything in a buffer is sent on dispose
            using (var azureSearchService = new AzureSearchService(AzureSearchServiceName, _azureSearchApiKey))
            {
                try
                {
                    // create an index - if an existing index is required: azureSearchService.GetIndexAsync()
                    var index = await azureSearchService.CreateIndexForLogAsync(INDEX_NAME);

                    var indexer = azureSearchService.CreateIndexerForLog(
                        index.Name,
                        documentsPerBatch: 1);

                    var web3 = new Web3.Web3(BlockchainUrl);

                    var blockchainProcessor = web3.Processing.Logs.CreateProcessor(
                        action: log => indexer.IndexAsync(log),
                        criteria: log => AddressUtil.Current.AreAddressesTheSame(log.Address, "0x9edcb9a9c4d34b5d6a082c86cb4f117a1394f831"));

                    var cancellationTokenSource = new CancellationTokenSource();
                    await blockchainProcessor.ExecuteAsync(3146685, cancellationTokenSource.Token, 3146684);

                    await Task.Delay(5000); // allow time to index

                    Assert.Equal(2, await azureSearchService.CountDocumentsAsync(INDEX_NAME));
                }
                finally
                {
                    await azureSearchService.DeleteIndexAsync(INDEX_NAME);
                }
            }
        }
        public async Task FilterLogs()
        {
            const string INDEX_NAME = "filter-logs";

            //surround with "using" so that anything in a buffer is sent on dispose
            //to clear the buffer manually - searchIndexProcessor.EventIndexer.SubmitPendingItemsAsync()
            using (var azureSearchService = new AzureSearchService(AzureSearchServiceName, _azureSearchApiKey))
            {
                try
                {
                    // create an index - if an existing index is required: azureSearchService.GetIndexAsync()
                    var index = await azureSearchService.CreateIndexForLogAsync(INDEX_NAME);

                    var indexer                 = azureSearchService.CreateIndexerForLog(index.Name, documentsPerBatch: 1);
                    var web3                    = new Web3.Web3(BlockchainUrl);
                    var blockchainProcessor     = web3.Processing.Logs.CreateProcessor(log => indexer.IndexAsync(log));
                    var cancellationTokenSource = new CancellationTokenSource();
                    await blockchainProcessor.ExecuteAsync(3146685, cancellationTokenSource.Token, 3146684);

                    await Task.Delay(5000); // allow time to index

                    Assert.Equal(25, await azureSearchService.CountDocumentsAsync(INDEX_NAME));
                }
                finally
                {
                    await azureSearchService.DeleteIndexAsync(INDEX_NAME);
                }
            }
        }
        public async Task PendingItemsBuffer()
        {
            const string INDEX_NAME = "filter-logs-clearing-buffer";

            using (var azureSearchService = new AzureSearchService(AzureSearchServiceName, _azureSearchApiKey))
            {
                try
                {
                    // create an index - if an existing index is required: azureSearchService.GetIndexAsync()
                    var index = await azureSearchService.CreateIndexForLogAsync(INDEX_NAME);

                    var indexer = azureSearchService.CreateIndexerForLog(INDEX_NAME, documentsPerBatch: 10);

                    var web3 = new Web3.Web3(BlockchainUrl);
                    var blockchainProcessor     = web3.Processing.Logs.CreateProcessor(log => indexer.IndexAsync(log));
                    var cancellationTokenSource = new CancellationTokenSource();

                    //execute
                    await blockchainProcessor.ExecuteAsync(3146685, cancellationTokenSource.Token, 3146684);

                    //as the indexer processes in batches and we've dictated a size of 10 items per batch
                    //we should have a buffer of items pending submission
                    //these are processed on disposal - but we can force this process manually
                    Assert.Equal(5, indexer.PendingDocumentCount);
                    Assert.Equal(20, indexer.Indexed);
                    //process the pending items
                    await indexer.IndexPendingDocumentsAsync();

                    //the buffer should be clear now
                    Assert.Equal(0, indexer.PendingDocumentCount);
                    Assert.Equal(25, indexer.Indexed);

                    await Task.Delay(5000); // allow time for Azure to index

                    Assert.Equal(25, await azureSearchService.CountDocumentsAsync(INDEX_NAME));
                }
                finally
                {
                    await azureSearchService.DeleteIndexAsync(INDEX_NAME);
                }
            }
        }