es_test.go 863 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package elastic
  2. import (
  3. "log"
  4. "testing"
  5. )
  6. type AggregationsBucket struct {
  7. Key string `json:"key"`
  8. Doc_count int `json:"doc_count"`
  9. Count struct {
  10. Value float64 `json:value`
  11. } `json:"count"`
  12. }
  13. func TestGet(t *testing.T) {
  14. q := `{
  15. "query": {
  16. "bool": {
  17. "must": [
  18. {
  19. "term": {
  20. "id": "64e6b70abc72bfca100f4b63"
  21. }
  22. }
  23. ]
  24. }
  25. }
  26. }`
  27. NewEs("v7", "http://127.0.0.1:19805", 2, "elastic", "MsOCrY7Yct3sjVvB5gCd")
  28. //NewEs("v1", "http://192.168.3.206:9800", 2, "", "")
  29. list := Get("bidding", "bidding", q)
  30. log.Println(list)
  31. }
  32. func TestAnalyze(t *testing.T) {
  33. NewEs("v7", "http://192.168.3.241:9205,http://192.168.3.149:9200", 2, "", "")
  34. //NewEs("v1", "http://192.168.3.206:9800", 2, "", "")
  35. res := Analyze("软件中国", "bidding", "ik_smart")
  36. log.Println(res)
  37. }