public void AllInOne() { string indexType = "v1"; var dict = new Dictionary <string, object>(); dict.Add("age", 22); var result = client.Index(app, indexType, "key1", dict); Assert.AreEqual(true, result.Success); var indexItem1 = new IndexItem("testKey"); indexItem1.Add("age", 21); result = client.Index(app, indexItem1); Assert.AreEqual(true, result.Success); var indexItem = new IndexItem(indexType, "key2"); indexItem.Add("age", 23); result = client.Index(app, indexItem); Assert.AreEqual(true, result.Success); client.Refresh(); var count = client.Count(app, indexType, ExpressionEx.Eq("age", 25)); Assert.AreEqual(0, count); count = client.Count(app, indexType, Conditional.Get(ExpressionEx.Eq("age", 22))); Assert.AreEqual(1, count); count = client.Count(app, indexType, Conditional.Get(ExpressionEx.Eq("age", 23))); Assert.AreEqual(1, count); count = client.Count(app, indexType, Conditional.Get(ExpressionEx.Between("age", 22, 23, true))); Assert.AreEqual(2, count); //a coplex example var cond1 = Conditional.Get(ExpressionEx.Eq("name", "jack")) .And(ExpressionEx.Between("age", 22, 30)) .And(ExpressionEx.Fuzzy("address", "beijing", 1.0f, 4)) .And(ExpressionEx.Le("no", 87)); Conditional cond2 = Conditional.Or(cond1, Conditional.Not(ExpressionEx.Eq("gender", "male"))); client.Search("index", "type", cond2.Query); }
public int Count(string index, string type, ExpressionEx expression) { return(Count(index, type, Conditional.Get(expression).Query)); }
public SearchResult Search(string index, string[] type, ExpressionEx expression, int from, int size) { return(Search(index, type, Conditional.Get(expression), from, size)); }