|
@@ -0,0 +1,41 @@
|
|
|
+package elastic
|
|
|
+
|
|
|
+import (
|
|
|
+ "log"
|
|
|
+ "testing"
|
|
|
+)
|
|
|
+
|
|
|
+type AggregationsBucket struct {
|
|
|
+ Key string `json:"key"`
|
|
|
+ Doc_count int `json:"doc_count"`
|
|
|
+ Count struct {
|
|
|
+ Value float64 `json:value`
|
|
|
+ } `json:"count"`
|
|
|
+}
|
|
|
+
|
|
|
+func TestGet(t *testing.T) {
|
|
|
+ q := `{
|
|
|
+ "query": {
|
|
|
+ "bool": {
|
|
|
+ "must": [
|
|
|
+ {
|
|
|
+ "term": {
|
|
|
+ "id": "64e6b70abc72bfca100f4b63"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }`
|
|
|
+ NewEs("v7", "http://127.0.0.1:19805", 2, "elastic", "MsOCrY7Yct3sjVvB5gCd")
|
|
|
+ //NewEs("v1", "http://192.168.3.206:9800", 2, "", "")
|
|
|
+ list := Get("bidding", "bidding", q)
|
|
|
+ log.Println(list)
|
|
|
+}
|
|
|
+
|
|
|
+func TestAnalyze(t *testing.T) {
|
|
|
+ NewEs("v7", "http://192.168.3.241:9205,http://192.168.3.149:9200", 2, "", "")
|
|
|
+ //NewEs("v1", "http://192.168.3.206:9800", 2, "", "")
|
|
|
+ res := Analyze("软件中国", "bidding", "ik_smart")
|
|
|
+ log.Println(res)
|
|
|
+}
|