I'm trying to connect to manticore database using the official go-sdk. I use the docs instructions expect I've added a DROP and a CREATE statement in order to create testrt index programmatically.
func FillManticore(w http.ResponseWriter, r *http.Request) {
sess := session.Instance(r)
cl := manticore.NewClient()
cl.SetServer("localhost", 9312)
cl.Open()
q := "DROP TABLE testrt"
res, err := cl.Sphinxql(q)
if err != nil {
fmt.Println("create error:", q)
}
q = "CREATE TABLE testrt(id int, title text, content text, counter int)"
fmt.Println("create query is:", q)
res, err = cl.Sphinxql(q)
if err != nil {
fmt.Println("create error:", q)
}
res, err = cl.Sphinxql(`replace into testrt values(1,'my subject', 'my content', 15)`)
fmt.Println(res, err)
res, err = cl.Sphinxql(`replace into testrt values(2,'another subject', 'more content', 15)`)
fmt.Println(res, err)
res, err = cl.Sphinxql(`replace into testrt values(5,'again subject', 'one more content', 10)`)
fmt.Println(res, err)
res2, err2 := cl.Query("subject", "testrt")
fmt.Println(res2, err2)
But I get:
[ERROR 1064 (42000): no such local index 'testrt'] <nil>
[ERROR 1064 (42000): no such local index 'testrt'] <nil>
[ERROR 1064 (42000): no such local index 'testrt'] <nil>
<nil> <nil>
The docs is really spare so I could not figure out what is wrong there with my code. So I appreciate your hints.
The wrong thing is that you can't add column named
idas there's one by default. If you try the same query directly with mysql client you'll get:Here's the fixed code:
which returns:
The diff is: