private static void UserQueryMode(IIndex index, NotebooksFileDataSource storage) { Console.CancelKeyPress += new ConsoleCancelEventHandler(CancelHandler); Stopwatch stopWatch = new Stopwatch(); var searcher = new EtSearcher(index, storage); while (true) { Console.WriteLine(); Console.Write("Enter the query: "); string query = Console.ReadLine(); stopWatch.Reset(); stopWatch.Start(); try { var result = searcher.Search(query); stopWatch.Stop(); PrintResults(result, stopWatch.ElapsedMilliseconds, storage); } catch { Console.WriteLine(); Console.WriteLine("Invalid query format"); Console.WriteLine(); } } }
private static void DemoSearch(IIndex index, NotebooksFileDataSource storage) { var queries = new[] { "apple && 13", "iru || samsung", "apple air && ! 11 && ! 11.6" }; Stopwatch stopWatch = new Stopwatch(); var searcher = new EtSearcher(index, storage); foreach (var query in queries) { Console.WriteLine(); Console.Write($"Searching {query}:"); stopWatch.Reset(); stopWatch.Start(); try { var result = searcher.Search(query); stopWatch.Stop(); PrintResults(result, stopWatch.ElapsedMilliseconds, storage); } catch { Console.WriteLine(); Console.WriteLine("Invalid query format"); Console.WriteLine(); } } }