//添加link到es搜索; contextType:0: url, 1:文本 func addLinkForSearch(contextType int, m map[string]interface{}, linkId int64, userName string) { m["id"] = linkId m["username"] = userName if contextType == 0 { m["host"] = utils.GetUrlHost(m["context"].(string)) m["context"] = "" } else { m["host"] = "" } ls := utils.LinkSearch{} ls.AddLink(m) }
//添加link到es搜索; contextType:0: url, 1:文本 func addLinkForSearch(contextType int, linkId int64, title string, context string, topics string, userName string) { m := make(map[string]interface{}) m["id"] = linkId m["title"] = title m["context"] = context m["topics"] = topics m["username"] = userName if contextType == 0 { m["host"] = utils.GetUrlHost(m["context"].(string)) m["context"] = "" } else { m["host"] = "" } ls := utils.LinkSearch{} _, err := ls.AddLink(m) if err != nil { fmt.Println("失败: ", m) } else { fmt.Println("成功: ", m) } }