public void SearchAzulTest() { string rootPath = "PROXYTEST"; string jsonParam = @" { ""index"": [ {""wd"":""arte"",""it"":[""Item1"",""Item2""]}, {""wd"":""aula"",""it"":[""Item1""]}, {""wd"":""azul"",""it"":[""Item3""]}, {""wd"":""bola"",""it"":[""Item2""]}, {""wd"":""casa"",""it"":[""Item2""]} ], ""items"":[ {""it"":""Item1"",""sc"":1}, {""it"":""Item2"",""sc"":2}, {""it"":""Item3"",""sc"":3} ] }"; var connection = new RedisTestConnector().Connect(); var proxy = new RedisAutoCompleteProxy(() => connection.GetDatabase()); proxy.Clear(rootPath); proxy.InsertItems(rootPath, jsonParam).Wait(); var result = proxy.Search(rootPath, JsonConvert.SerializeObject(new { prefixes = new[] { "a" } }), 15, 10).Result; Assert.AreEqual(3, result.Length); Assert.IsTrue(result.Contains("Item1")); Assert.IsTrue(result.Contains("Item2")); Assert.IsTrue(result.Contains("Item3")); result = proxy.Search(rootPath, JsonConvert.SerializeObject(new { prefixes = new[] { "az" } }), 15, 10).Result; Assert.AreEqual(1, result.Length); Assert.IsTrue(result.Contains("Item3")); connection.Close(); }
public void SearchTest() { string rootPath = "PROXYTEST"; string jsonParam = @" { ""index"": [ {""wd"":""hello"",""it"":[""Item1"",""Item2""]}, {""wd"":""world"",""it"":[""Item1""]}, {""wd"":""holland"",""it"":[""Item2""]} ], ""items"":[ {""it"":""Item1"",""sc"":1}, {""it"":""Item2"",""sc"":2} ] }"; var connection = new RedisTestConnector().Connect(); var proxy = new RedisAutoCompleteProxy(() => connection.GetDatabase()); proxy.Clear(rootPath); proxy.InsertItems(rootPath, jsonParam).Wait(); var result = proxy.Search(rootPath,JsonConvert.SerializeObject(new {prefixes = new[] {"hol"}}), 15, 10).Result; Assert.AreEqual(1, result.Length); Assert.AreEqual("Item2", result[0]); connection.Close(); }