|
|
@@ -15,13 +15,13 @@ var (
|
|
|
)
|
|
|
|
|
|
type ParamIndex struct {
|
|
|
- Key string `json:"key"`
|
|
|
+ DocId string `json:"docId"`
|
|
|
Content string `json:"content"`
|
|
|
ForceUpdate bool `json:"forceUpdate"`
|
|
|
}
|
|
|
|
|
|
type ParamDelete struct {
|
|
|
- Key string `json:"key"`
|
|
|
+ DocId string `json:"docId"`
|
|
|
ForceUpdate bool `json:"forceUpdate"`
|
|
|
}
|
|
|
|
|
|
@@ -68,18 +68,7 @@ func stopHttp() {
|
|
|
}
|
|
|
|
|
|
func jsonBody(w *http.ResponseWriter, r *http.Request, v interface{}) error {
|
|
|
- //reader, err := r.GetBody()
|
|
|
- //if err != nil {
|
|
|
- // //log
|
|
|
- // return err
|
|
|
- //}
|
|
|
- //defer reader.Close()
|
|
|
- //
|
|
|
- //b, err := ioutil.ReadAll(reader)
|
|
|
- //if err != nil {
|
|
|
- // //log
|
|
|
- // return err
|
|
|
- //}
|
|
|
+ //http.MaxBytesReader(*w, r.Body, 10)
|
|
|
return json.NewDecoder(r.Body).Decode(v)
|
|
|
}
|
|
|
|
|
|
@@ -92,7 +81,7 @@ func index_v1(w http.ResponseWriter, r *http.Request) {
|
|
|
return
|
|
|
}
|
|
|
fmt.Println("indexing:", param)
|
|
|
- searcher.IndexDocumentS(param.Key, types.DocumentIndexData{
|
|
|
+ searcher.IndexDocumentS(param.DocId, types.DocumentIndexData{
|
|
|
Content: param.Content,
|
|
|
}, param.ForceUpdate)
|
|
|
|
|
|
@@ -110,7 +99,7 @@ func delete_index_v1(w http.ResponseWriter, r *http.Request) {
|
|
|
}
|
|
|
fmt.Println("removing index:", param)
|
|
|
|
|
|
- searcher.RemoveDocumentS(param.Key, param.ForceUpdate)
|
|
|
+ searcher.RemoveDocumentS(param.DocId, param.ForceUpdate)
|
|
|
|
|
|
w.WriteHeader(http.StatusOK)
|
|
|
_, err = w.Write([]byte(`{"ec":0,"result":{}}`))
|