static async Task Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; IConfiguration config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .Build(); var elasticsearchSettings = new ElasticsearchSettings(); config.Bind(nameof(ElasticsearchSettings), elasticsearchSettings); var unitOfWork = new UnitOfWork(); var printService = new PrintService(); var elasticsearchService = new ElasticsearchService(elasticsearchSettings, unitOfWork, printService); await elasticsearchService.SeedDataAsync(); printService.PrintInfo($"Enter sesrch text (or quit to exit)...{Environment.NewLine}", false); // input search text: "1", "1st", "first", "one", "One", "ONe", "First", "FIRST", "FiRsT", "2nd", "avenue", "Avenue", "1 ave", "1 avenue", "ave" while (true) { Console.Write("> "); string search = Console.ReadLine(); if (search.Equals("quit", StringComparison.InvariantCultureIgnoreCase)) { break; } var result = await elasticsearchService.SearchAsync(search); printService.PrintInfo(result); printService.PrintInfo($"Total items founded by search='{search}': {result.Count()}{Environment.NewLine}", false); } }
public async Task Should_Find_For_Words(string keyword) { var es = new ElasticsearchService(INDEX_NAME); var res1 = await es.SearchAsync(keyword); Assert.IsTrue(res1.Total > 0); }