public void TestCreatingMapping() { var index = "index_operate" + Guid.NewGuid(); var stringFieldSetting = new StringFieldSetting { Analyzer = "standard", Type = "string", NullValue = "mystr" }; var typeSetting = new TypeSetting("custom_type"); typeSetting.AddFieldSetting("medcl", stringFieldSetting); var typeSetting2 = new TypeSetting("hell_type1"); var numfield = new NumberFieldSetting { Store = Store.yes, NullValue = 0.00 }; typeSetting2.AddFieldSetting("name", numfield); client.CreateIndex(index); var result = client.PutMapping(index, typeSetting); Assert.AreEqual(true, result.Success); result = client.PutMapping(index, typeSetting2); Assert.AreEqual(true, result.Success); var result2 = client.DeleteIndex(index); Assert.AreEqual(true, result2.Success); }
public void Init() { var typesetting = new TypeSetting("type"); typesetting.AddFieldSetting("name", new StringFieldSetting() { Index = IndexType.not_analyzed }); typesetting.AddFieldSetting("id", new NumberFieldSetting() { }); typesetting.AddFieldSetting("gender", new BooleanFieldSetting() { Index = IndexType.not_analyzed }); client.CreateIndex(index); client.PutMapping(index, typesetting); IndexItem item; for (int i = 0; i < 100; i++) { item = new IndexItem("type", i.ToString()); item.Add("name", Guid.NewGuid().ToString()); item.Add("id", i); item.Add("ids","ids_{0}".Fill(i)); if (i >= 50) { item.Add("gender", true); } else { item.Add("gender", false); } client.Index(index,item); } item = new IndexItem("type", "addition_key2"); item.Add("name", "张"); item.Add("age",25); item.Add("type","common"); client.Index(index, item); item = new IndexItem("type", "addition_key3"); item.Add("name", "张三"); item.Add("age", 24); item.Add("type", "common"); client.Index(index, item); item = new IndexItem("type", "addition_key4"); item.Add("name", "张三丰"); item.Add("age", 23); item.Add("type", "common"); client.Index(index, item); item = new IndexItem("type", "addition_key5"); item.Add("name", "二张三张"); item.Add("age", 22); item.Add("type", "common2"); client.Index(index, item); Thread.Sleep(1000); }