golang 利用Sphinxql 操作Manticore Search
Manticore Search : git地址 https://github.com/manticoresoftware/manticoresearch
docker 安装启动步骤
安装参考链接:https://blog.csdn.net/qq_19309473/article/details/132096295
1、docker pull manticoresearch/manticore
2、docker run --name manticore -p 127.0.0.1:9306:9306 -p 127.0.0.1:9308:9308 -d manticoresearch/manticore
下面3,4可以防止容器停止后 重启导致之前的数据丢失 具体含义参考百度(就是映射容器的数据到宿主机)
3、docker cp 6593d73bd657:/etc/manticoresearch/manticore.conf C:/Users/admin/Desktop/manticore/ (先运行起来把配置文件从容器拷贝出来 不然会报错)
4、docker run -e EXTRA=1 --name manticore -v C:/Users/admin/Desktop/manticore/manticore.conf:/etc/manticoresearch/manticore.conf -v C:/Users/admin/Desktop/manticore/data:/var/lib/manticore/ -p 127.0.0.1:9306:9306 -p 127.0.0.1:9308:9308 -d manticoresearch/manticore
package main
import (
"fmt"
"github.com/manticoresoftware/go-sdk/manticore"
)
func main() {
cl := manticore.NewClient()
cl.SetServer("127.0.0.1", 9308)
cl.Open()
//sql := `CREATE TABLE game_pub(id int,main_type text,main_label text)`
//// 建表
//res, err := cl.Sphinxql(sql)
//fmt.Println(res, err)
// 删表
//res, err := cl.Sphinxql(`DROP TABLE game_pub`)
//fmt.Println(res, err)
// 查看有哪些表
//res, err := cl.Sphinxql(`SHOW TABLES;`)
//fmt.Println(res, err)
// 查看表字段
res, err := cl.Sphinxql(`SHOW FIELDS FROM game_pub`)
fmt.Println(res, err)
// 新增数据
//res, err := cl.Sphinxql(`insert into movies(title, year) values ('The Seven Samurai', 1954), ('Bonnie and Clyde', 1954), ('Reservoir Dogs', 1992), ('Airplane!', 1980), ('Raging Bull', 1980), ('Groundhog Day', 1993), ('<a href="http://google.com/">Jurassic Park</a>', 1993), ('Ferris Bueller\'s Day Off', 1986)`)
//fmt.Println(res, err)
// 有事问 AI
// 查询
//res, err := cl.Sphinxql(`select * from movies where year=1954`)
//fmt.Println(res, err)
//
//// 修改
//res, err = cl.Sphinxql(`UPDATE movies SET year = 2020 WHERE id = 8216970693133205505`)
//fmt.Println(res, err)
//
//// 查询
//res, err = cl.Sphinxql(`select * from movies where year=2020`)
//fmt.Println(res, err)
//
//// 删除
//res, err = cl.Sphinxql(`DELETE FROM movies WHERE id = 8216970693133205505`)
//fmt.Println(res, err)
//
//// 查询
//res, err = cl.Sphinxql(`select * from movies where year=2020`)
//fmt.Println(res, err)
//res2, err2 := cl.Query("more|another", "testrt")
//fmt.Println(res2, err2)
}