static void TestCase1() { List <string> docsToIndex = DocumentsToIndex("./TestCases/1/"); List <string> queriesToProcess = QueriesToProcess("./TestCases/1/"); ParseOptions options = new ParseOptions(); // load documents foreach (string curr in docsToIndex) { byte[] data = Common.ReadBinaryFile(curr); SourceDocument src = new SourceDocument("test", "test", curr, curr, null, DocType.Json, null, "application/json", data.Length, Common.Md5(data)); IndexResult result = _IndexClient.Add(src, data, options, true).Result; Console.WriteLine(""); Console.WriteLine("Add: " + curr); Console.WriteLine(Common.SerializeJson(result, true)); } Console.WriteLine(""); Console.WriteLine("Press ENTER to continue"); Console.ReadLine(); // execute queries foreach (string curr in queriesToProcess) { SearchQuery query = Common.DeserializeJson <SearchQuery>(Common.ReadBinaryFile(curr)); SearchResult result = _IndexClient.Search(query); Console.WriteLine(""); Console.WriteLine("Query: " + curr); Console.WriteLine(Common.SerializeJson(result, true)); } }
/// <summary> /// Search the index. /// </summary> /// <param name="indexName">Name of the index.</param> /// <param name="query">Search query.</param> /// <returns>Search result.</returns> public SearchResult Search(string indexName, SearchQuery query) { if (String.IsNullOrEmpty(indexName)) { throw new ArgumentNullException(nameof(indexName)); } if (query == null) { throw new ArgumentNullException(nameof(query)); } KomodoIndex idx = GetIndexClient(indexName); return(idx.Search(query)); }