|
@@ -16,22 +16,23 @@ var configFile = flag.String("f", "../etc/common.yaml", "the config file")
|
|
|
|
|
|
//es保存
|
|
|
func Test_esSave(t *testing.T) {
|
|
|
- conf.MustLoad(*configFile, &cf.CommonConfig)
|
|
|
+ var cfg cf.Config
|
|
|
+ conf.MustLoad(*configFile, &cfg)
|
|
|
//初始es
|
|
|
- es := cf.CommonConfig.Es
|
|
|
+ es := cfg.Es
|
|
|
model.InitEs(&es)
|
|
|
log.Println(es.Addr, "----", es.Size)
|
|
|
elastic.InitElasticSize("http://192.168.3.206:9800", es.Size)
|
|
|
now := time.Now().Unix()
|
|
|
b := elastic.Save("supplyinfo_v1", "supplyinfo", &map[string]interface{}{
|
|
|
- "_id": "100006",
|
|
|
- "id": "100006",
|
|
|
+ "_id": "100016",
|
|
|
+ "id": "100016",
|
|
|
"msg_type": "1",
|
|
|
- "title": "一个信息消息字段可以含有一个如下类型,以及与之对应在自动生成访问类中定义类型",
|
|
|
- "detail": "这个理解起来有些晦涩,举例来说上面例子中三个字段都是singular类型的字段,在编码后的消息体中可以有0或者1个query字段,但不会有多个",
|
|
|
+ "title": "有趣信息",
|
|
|
+ "detail": "一只公鹿,它走着走着,越走越快,最后它变成了高速公路(鹿)! ",
|
|
|
"ent_name": "破产公司",
|
|
|
"province": "河南",
|
|
|
- "city": "郑州市",
|
|
|
+ "city": "南阳市",
|
|
|
"validity_time": now,
|
|
|
"create_time": now,
|
|
|
"publish_time": now,
|