Exemple #1
0
        public async Task ShouldUpdateDocument()
        {
            //Arrange
            var document = new TestEntity
            {
                Id    = 10,
                Value = "foo"
            };
            EsFound <TestEntity> found = null;

            //Act
            await _clFx.UseTmpIndexWithMap(async indNm =>
            {
                await _indexer.IndexAsync(indNm, document);

                await _indexer.UpdateAsync(indNm, document.Id, () => new TestEntity
                {
                    Value = "bar"
                });

                await Task.Delay(1000);

                found = await _searcher.SearchAsync(indNm, new SearchParams <TestEntity>(d => d.Ids(ids => ids.Values(document.Id))));
            });

            //Assert
            Assert.NotNull(found);
            Assert.Single(found);
            Assert.Equal("bar", found.First().Value);
        }
Exemple #2
0
        private async Task <EsFound <TestModel> > InvokeTest <TSearchEngine>(
            Func <IEsSearchEngine <TestModel>, Task <EsFound <TestModel> > > logic)
            where TSearchEngine : class, IEsSearchEngine <TestModel>
        {
            IServiceProvider    sp    = null;
            EsFound <TestModel> found = null;

            try
            {
                sp = StartSearchApp <TSearchEngine>();

                var searchEngine = sp.GetService <IEsSearchEngine <TestModel> >();
                var mgr          = sp.GetService <IEsManager>();
                var indexer      = sp.GetService <IEsIndexer <TestModel> >();

                await using (await mgr.CreateDefaultIndexAsync())
                {
                    await indexer.IndexManyAsync(Models);

                    await Task.Delay(1000);

                    //Act
                    found = await logic(searchEngine);
                }
            }
            catch (EsSearchException <TestModel> e)
            {
                _output.WriteLine(e.Response.DebugInformation);
            }
            finally
            {
                CloseSearchApp(sp);
            }

            return(found);
        }