Esempio 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);
        }
 public AzureTransactionReceiptVOIndexer(
     ISearchIndexClient indexClient,
     TransactionReceiptVOIndexDefinition indexDefinition,
     int documentsPerIndexBatch = 1
     )
     : base(indexClient, (tx) => tx.ToAzureDocument(indexDefinition), documentsPerIndexBatch)
 {
 }
Esempio n. 3
0
        public IIndexer <TransactionReceiptVO> CreateIndexerForTransactionReceiptVO(
            string indexName, TransactionReceiptVOIndexDefinition indexDefinition, int documentsPerBatch = 1)
        {
            var indexClient  = GetOrCreateIndexClient(indexName);
            var azureIndexer = new AzureTransactionReceiptVOIndexer(indexClient, indexDefinition, documentsPerBatch);

            _indexers.Add(azureIndexer);
            return(azureIndexer);
        }
Esempio n. 4
0
 public ElasticTransactionReceiptVOIndexer(
     string indexName,
     IElasticClient indexClient,
     TransactionReceiptVOIndexDefinition indexDefinition,
     int documentsPerIndexBatch = 1
     )
     : base(indexName, indexClient, (tx) => tx.ToGenericElasticSearchDoc(indexDefinition), documentsPerIndexBatch)
 {
 }
Esempio n. 5
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()]);
        }
        public async Task MapsTransactionToGenericSearchDocument()
        {
            var indexDefinition       = new TransactionReceiptVOIndexDefinition("my-transactions");
            var index                 = indexDefinition.ToAzureIndex();
            var mockSearchIndexClient = new SearchIndexClientMock <GenericSearchDocument>();

            var indexer = new AzureTransactionReceiptVOIndexer(
                mockSearchIndexClient.SearchIndexClient, indexDefinition);

            TransactionReceiptVO transaction = IndexerTestData.CreateSampleTransaction();

            await indexer.IndexAsync(transaction);

            Assert.Single(mockSearchIndexClient.IndexedBatches);
            var firstIndexAction = mockSearchIndexClient.IndexedBatches[0].Actions.First();
            var document         = firstIndexAction.Document;

            //check generic mapping
            Assert.Equal(transaction.Transaction.BlockNumber.ToString(), document[PresetSearchFieldName.tx_block_number.ToString()]);
        }
        public static GenericSearchDocument ToGenericElasticSearchDoc(
            this TransactionReceiptVO transactionReceiptVO,
            TransactionReceiptVOIndexDefinition indexDefinition)
        {
            var dictionary = new GenericSearchDocument();

            foreach (var field in indexDefinition.Fields)
            {
                var val = field.GetTransactionReceiptValue(transactionReceiptVO)?.ToElasticSearchFieldValue();
                if (val != null)
                {
                    dictionary.Add(field.Name.ToElasticName(), val);
                }
            }

            var id = transactionReceiptVO.TransactionHash;

            dictionary.SetId(id.ToString());

            return(dictionary);
        }
Esempio n. 8
0
 public static GenericSearchDocument ToAzureDocument(
     this TransactionReceiptVO transactionReceiptVO,
     TransactionReceiptVOIndexDefinition indexDefinition)
 {
     return(CreateFieldWithValueDictionary(transactionReceiptVO, indexDefinition.Fields, (field) => field.GetTransactionReceiptValue(transactionReceiptVO)));
 }