|
@@ -1,8 +1,10 @@
|
|
|
package elastic
|
|
|
|
|
|
import (
|
|
|
+ "encoding/json"
|
|
|
"log"
|
|
|
_ "log"
|
|
|
+ "net/url"
|
|
|
|
|
|
_ "gopkg.in/mgo.v2/bson"
|
|
|
_ "gopkg.in/olivere/elastic.v1"
|
|
@@ -81,3 +83,17 @@ func Test_saveToEs(t *testing.T) {
|
|
|
"title": "你好,试试2",
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+func Test_word(t *testing.T) {
|
|
|
+ InitElasticSize("http://192.168.3.207:9700", 2)
|
|
|
+ es := GetEsConn()
|
|
|
+ defer DestoryEsConn(es)
|
|
|
+ p := url.Values{}
|
|
|
+ p["text"] = []string{"中华人民共和国"}
|
|
|
+ p["analyzer"] = []string{"ik_pinyin"}
|
|
|
+ by, err := es.PerformRequest("GET", "/test1/_analyze", p, nil)
|
|
|
+ b, _ := by.Body.MarshalJSON()
|
|
|
+ var res map[string]interface{}
|
|
|
+ json.Unmarshal(b, &res)
|
|
|
+ log.Println(res, err)
|
|
|
+}
|