task.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. package services
  2. import (
  3. "fmt"
  4. )
  5. func Task() {
  6. fmt.Println("start")
  7. //keyWord := "专家"
  8. //pageSize := 20
  9. //SearchByKeyWord(keyWord, pageSize)
  10. //SaveData()
  11. //GetIndustryMap()
  12. //解析报告
  13. //GetArticleExpert()
  14. //SearchByKeyWordQuery("")
  15. //AddMap()
  16. //同步数据
  17. //ImportData()
  18. //AddMap()
  19. //Search("光伏行业")
  20. //修复报告内容
  21. //GetArticleAll()
  22. //indexName := "article_list"
  23. // mappingJson := `{
  24. //"mappings": {
  25. // "dynamic": true,
  26. // "properties": {
  27. // "ArticleId": {
  28. // "type": "integer"
  29. // },
  30. // "Title": {
  31. // "type": "text",
  32. // "analyzer": "ik_smart"
  33. // },
  34. // "TitleEn": {
  35. // "type": "text",
  36. // "analyzer": "ik_smart"
  37. // },
  38. // "UpdateFrequency": {
  39. // "type": "text",
  40. // "analyzer": "ik_smart"
  41. // },
  42. // "CreateDate": {
  43. // "type": "text",
  44. // "analyzer": "ik_smart"
  45. // },
  46. // "PublishDate": {
  47. // "type": "text",
  48. // "analyzer": "ik_smart"
  49. // },
  50. // "Abstract": {
  51. // "type": "text",
  52. // "analyzer": "ik_smart"
  53. // },
  54. // "CategoryName": {
  55. // "type": "text",
  56. // "analyzer": "ik_smart"
  57. // },
  58. // "SubCategoryName": {
  59. // "type": "text",
  60. // "analyzer": "ik_smart"
  61. // },
  62. // "InterviewDate": {
  63. // "type": "text",
  64. // "analyzer": "ik_smart"
  65. // },
  66. // "ExpertBackground": {
  67. // "type": "text",
  68. // "analyzer": "ik_smart"
  69. // },
  70. // "ExpertNumber": {
  71. // "type": "text",
  72. // "analyzer": "ik_smart"
  73. // },
  74. // "Department": {
  75. // "type": "text",
  76. // "analyzer": "ik_smart"
  77. // },
  78. // "BodyText": {
  79. // "type": "text",
  80. // "analyzer": "ik_smart"
  81. // },
  82. // "ArticleIdMd5": {
  83. // "type": "text",
  84. // "analyzer": "ik_smart"
  85. // }
  86. // }
  87. //}
  88. //}`
  89. // EsCreateIndex(indexName,mappingJson)
  90. //插入数据
  91. //allList, err := models.GetArticleAll()
  92. //if err != nil {
  93. // fmt.Println("GetArticleAll Err:", err.Error())
  94. // return
  95. //}
  96. //
  97. ////indexName := "article"
  98. //
  99. //for _, v := range allList {
  100. // content := html.UnescapeString(v.Body)
  101. // doc, err := goquery.NewDocumentFromReader(strings.NewReader(content))
  102. // if err != nil {
  103. // fmt.Println("create doc err:", err.Error())
  104. // return
  105. // }
  106. // bodyText := doc.Text()
  107. //
  108. // item := new(ElasticArticleDetail)
  109. // item.ArticleId = v.ArticleId
  110. // item.Title = v.Title
  111. // item.TitleEn = v.TitleEn
  112. // item.UpdateFrequency = v.UpdateFrequency
  113. // item.CreateDate = v.CreateDate
  114. // item.PublishDate = v.PublishDate
  115. // item.Abstract = v.Abstract
  116. // item.CategoryName = v.CategoryName
  117. // item.SubCategoryName = v.SubCategoryName
  118. // item.InterviewDate = v.InterviewDate
  119. // item.ExpertBackground = v.ExpertBackground
  120. // item.ExpertNumber = v.ExpertNumber
  121. // item.Department = v.Department
  122. // item.ArticleIdMd5 = v.ArticleIdMd5
  123. // item.BodyText = bodyText
  124. // EsAddData(indexName, strconv.Itoa(v.ArticleId), item)
  125. //}
  126. fmt.Println("end")
  127. }
  128. type ElasticArticleDetail struct {
  129. ArticleId int `description:"报告id"`
  130. Title string `description:"标题"`
  131. TitleEn string `description:"英文标题 "`
  132. UpdateFrequency string `description:"更新周期"`
  133. CreateDate string `description:"创建时间"`
  134. PublishDate string `description:"发布时间"`
  135. Abstract string `description:"摘要"`
  136. CategoryName string `description:"一级分类"`
  137. SubCategoryName string `description:"二级分类"`
  138. InterviewDate string `description:"访谈时间"`
  139. ExpertBackground string `description:"专家背景"`
  140. ExpertNumber string `description:"专家编号"`
  141. Department string `description:"作者"`
  142. ArticleIdMd5 string `description:"纪要id"`
  143. BodyText string `description:"内容"`
  144. }