public async Task InitializeAsync()
        {
            _index = await TmpIndexLife <TDoc> .CreateAsync(EsClient);

            Searcher = new EsSearcher <TDoc>(new SingleEsClientProvider(EsClient), null, (ElasticsearchOptions)null).ForIndex(_index.IndexName);
            Manager  = new EsManager(new SingleEsClientProvider(EsClient), (ElasticsearchOptions)null);
            Indexer  = new EsIndexer <TDoc>(new SingleEsClientProvider(EsClient), null, (ElasticsearchOptions)null).ForIndex(_index.IndexName);
        }
예제 #2
0
        /// <summary>
        /// Creates index for the duration of function performing
        /// </summary>
        public async Task <TRes> UseTmpIndex <TRes>(Func <TestServices <TDoc>, Task <TRes> > func, string tmpIndexName = null)
        {
            await using var indexLife = await TmpIndexLife <TDoc> .CreateAsync(_client, tmpIndexName);

            var searcher = new EsSearcher <TDoc>(new SingleEsClientProvider(_client), null, (ElasticsearchOptions)null).ForIndex(indexLife.IndexName);
            var manager  = new EsManager(new SingleEsClientProvider(_client), (ElasticsearchOptions)null);
            var indexer  = new EsIndexer <TDoc>(new SingleEsClientProvider(_client), null, (ElasticsearchOptions)null).ForIndex(indexLife.IndexName);

            return(await func(new TestServices <TDoc>
            {
                IndexName = indexLife.IndexName,
                Indexer = indexer,
                Manager = manager,
                Searcher = searcher
            }));
        }
예제 #3
0
 /// <summary>
 /// Creates temp index
 /// </summary>
 public async Task <IAsyncDisposable> CreateTmpIndex(string tmpIndexName = null)
 {
     return(await TmpIndexLife <TDoc> .CreateAsync(_client, tmpIndexName));
 }