milvus init
This commit is contained in:
		
							
								
								
									
										27
									
								
								bin/main.go
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								bin/main.go
									
									
									
									
									
								
							@@ -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) // 最后打印日志
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user