elasticsearch.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package services
  2. import (
  3. "strings"
  4. )
  5. const (
  6. ES_URL = "http://es-cn-nif227b580019rgw6.public.elasticsearch.aliyuncs.com:9200" //<1>
  7. ES_USERNAME = "elastic" //<2>
  8. ES_PASSWORD = "hongze@2021" //<3>
  9. //Grafana pwd-> 20521bb9
  10. //Grafana username-> emon
  11. )
  12. func RemoveDuplicatesAndEmpty(a []string) (ret []string) {
  13. a_len := len(a)
  14. for i := 0; i < a_len; i++ {
  15. if (i > 0 && a[i-1] == a[i]) || len(a[i]) == 0 {
  16. continue
  17. }
  18. ret = append(ret, a[i])
  19. }
  20. return
  21. }
  22. // KeyWordArrSqlRegexp 预处理ik联想词的模糊查询语句
  23. func KeyWordArrSqlRegexp(a []string) (ret string) {
  24. a_len := len(a)
  25. for i := 0; i < a_len; i++ {
  26. if i == 0 {
  27. continue
  28. }
  29. ret += a[i] + "|"
  30. }
  31. ret = strings.TrimRight(ret, "|")
  32. return
  33. }
  34. // KeyWordArrSqlRegexp 预处理ik联想词的模糊查询语句
  35. func KeyWordArrSqlRegexpAll(a []string) (ret string) {
  36. a_len := len(a)
  37. for i := 0; i < a_len; i++ {
  38. ret += a[i] + "|"
  39. }
  40. ret = strings.TrimRight(ret, "|")
  41. //ret = "'" + ret + "'"
  42. return
  43. }