Exemplo n.º 1
0
        public IIndexer <TransactionReceiptVO> CreateIndexerForTransactionReceiptVO(
            string indexName, TransactionReceiptVOIndexDefinition indexDefinition, int documentsPerBatch)
        {
            var indexer = new ElasticTransactionReceiptVOIndexer(indexName, _elasticClient, indexDefinition, documentsPerBatch);

            _indexers.Add(indexer);
            return(indexer);
        }
Exemplo n.º 2
0
        public IIndexer <TransactionReceiptVO> CreateIndexerForTransactionReceiptVO <TSearchDocument>(
            string indexName, Func <TransactionReceiptVO, TSearchDocument> mapper, int documentsPerBatch)
            where TSearchDocument : class, IHasId
        {
            var indexer = new ElasticTransactionReceiptVOIndexer <TSearchDocument>(indexName, _elasticClient, mapper, documentsPerBatch);

            _indexers.Add(indexer);
            return(indexer);
        }
        public async Task MapsTransactionToSearchDocument()
        {
            var mockElasticClient = new MockElasticClient();

            var indexer = new ElasticTransactionReceiptVOIndexer <SearchDocument>("my-index",
                                                                                  mockElasticClient.ElasticClient, (tx) => new SearchDocument(tx));

            TransactionReceiptVO transaction = IndexerTestData.CreateSampleTransaction();

            await indexer.IndexAsync(transaction);

            Assert.Single(mockElasticClient.BulkRequests);
            var indexedDocument = mockElasticClient.GetFirstBulkOperation().GetBody() as SearchDocument;

            //check mapping
            Assert.Same(transaction, indexedDocument.TransactionReceiptVO);
        }
Exemplo n.º 4
0
        public async Task MapsTransactionToGenericSearchDocument()
        {
            var indexDefinition   = new TransactionReceiptVOIndexDefinition("my-transactions");
            var mockElasticClient = new MockElasticClient();

            var indexer = new ElasticTransactionReceiptVOIndexer("my-index",
                                                                 mockElasticClient.ElasticClient, indexDefinition);

            TransactionReceiptVO transaction = IndexerTestData.CreateSampleTransaction();

            await indexer.IndexAsync(transaction);

            Assert.Single(mockElasticClient.BulkRequests);
            var indexedDoc = mockElasticClient.GetFirstBulkOperation().GetBody() as GenericSearchDocument;

            //check generic mapping
            Assert.Equal(transaction.Transaction.BlockNumber.ToString(), indexedDoc[PresetSearchFieldName.tx_block_number.ToString()]);
        }