es_test.go 764 B

123456789101112131415161718192021222324252627282930313233
  1. package main
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "testing"
  6. )
  7. func TestMatchService(t *testing.T) {
  8. data := `{
  9. "_id" : "6422d91e779467cff1a84885",
  10. "area" : "全国",
  11. "city" : "",
  12. "extracttype" : 0,
  13. "s_sha" : "d7cc66ac91dc6551991df0a37331b628de4c70973c6844f1ee6ef1c2d4e29e95",
  14. "jsondata" : {
  15. "area_city_district" : "福建",
  16. "buyer" : "莆田市第一医院",
  17. "item" : " 货物/医药品/医用材料/其他医用材料",
  18. "agency" : "福建省荔卫药械招标服务有限公司"
  19. },
  20. "channel" : "地方公告"
  21. }`
  22. var obj map[string]interface{}
  23. if err := json.Unmarshal([]byte(data), &obj); err != nil {
  24. panic(err)
  25. }
  26. objectType := MatchService(obj)
  27. fmt.Println("objectType=>", objectType)
  28. }