milvus init

This commit is contained in:
2023-04-11 23:16:51 +08:00
parent 9dcdd3e93c
commit 75eb74bac3
5 changed files with 121 additions and 15 deletions

View File

@@ -17,10 +17,6 @@ import (
_ "github.com/go-sql-driver/mysql"
)
//func init() {
// log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
//}
// string 转换为 int, 如果转换失败则返回默认值
func stringToInt(str string, defaultValue int) int {
if str == "" {
@@ -66,6 +62,9 @@ func main() {
var mysqlConnection models.MysqlConnection
mysqlConnection.Init()
var milvusConnection models.MilvusConnection
milvusConnection.Init()
// 获取标签列表
http.HandleFunc("/tags", func(w http.ResponseWriter, r *http.Request) {
defer LogComponent(time.Now().UnixNano(), r) // 最后打印日志
@@ -187,6 +186,26 @@ func main() {
**/
})
//// 获取相似图片列表
//http.HandleFunc("/similar", func(w http.ResponseWriter, r *http.Request) {
// defer LogComponent(time.Now().UnixNano(), r) // 最后打印日志
// id := "8888"
// // 先查询图片的向量在 mulvis 中是否存在
// var collection_name = "default" // 图片集合名称
// result, err := milvusConnection.Client.Query(
// context.Background(), // ctx
// collection_name, // CollectionName
// []string{}, // PartitionName
// fmt.Sprintf("id in [%s]", id), // expr
// []string{"book_id", "book_intro"}, // OutputFields
// )
// if err != nil {
// log.Println(err)
// return
// }
// log.Println(result)
//})
// 获取图片信息列表(分页)
http.HandleFunc("/images", func(w http.ResponseWriter, r *http.Request) {
defer LogComponent(time.Now().UnixNano(), r) // 最后打印日志