33 lines
717 B
Go
33 lines
717 B
Go
package service
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"myschools.me/suguo/search/exceptionless"
|
|
)
|
|
|
|
func indexAdd(id *uint32, uri, title, description *string) {
|
|
idx := &struct {
|
|
ID uint32
|
|
Text string
|
|
Document map[string]interface{}
|
|
}{
|
|
ID: *id,
|
|
Text: fmt.Sprintf("%s %s %s", *uri, *title, *description),
|
|
Document: map[string]interface{}{
|
|
"url": *uri,
|
|
"title": *title,
|
|
"description": *description,
|
|
},
|
|
}
|
|
body, _ := json.Marshal(idx)
|
|
dr := bytes.NewReader(body)
|
|
if _, err := http.Post("http://admin:123456@192.168.0.254:5678/api/index?database=default", "", dr); err != nil {
|
|
exceptionless.SubmitAppError("indexAdd", "http.Post", nil, err)
|
|
}
|
|
|
|
}
|