|
@@ -40,7 +40,6 @@ func Task() {
|
|
//toolbox.StartTask()
|
|
//toolbox.StartTask()
|
|
|
|
|
|
fmt.Println("end")
|
|
fmt.Println("end")
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
func ElasticOption() {
|
|
func ElasticOption() {
|
|
@@ -195,43 +194,74 @@ searchItem.Body = v.Highlight["BodyText"]
|
|
searchItem.Title = title
|
|
searchItem.Title = title
|
|
searchItem.PublishDate = article.PublishDate
|
|
searchItem.PublishDate = article.PublishDate
|
|
*/
|
|
*/
|
|
-func CreateIndex() {
|
|
|
|
- indexName := "cygx_article_test" //utils.IndexName
|
|
|
|
- mappingJson := `{
|
|
|
|
- "mappings": {
|
|
|
|
- "dynamic": true,
|
|
|
|
- "properties": {
|
|
|
|
- "ArticleId": {
|
|
|
|
- "type": "integer"
|
|
|
|
- },
|
|
|
|
- "BodyText": {
|
|
|
|
- "type": "text",
|
|
|
|
- "term_vector": "with_positions_offsets"
|
|
|
|
- },
|
|
|
|
- "PublishDate": {
|
|
|
|
- "type": "text"
|
|
|
|
- },
|
|
|
|
- "SubCategoryName": {
|
|
|
|
- "type": "text",
|
|
|
|
- "term_vector": "with_positions_offsets"
|
|
|
|
- },
|
|
|
|
- "Title": {
|
|
|
|
- "type": "text",
|
|
|
|
- "term_vector": "with_positions_offsets"
|
|
|
|
- },
|
|
|
|
- "TitleEn": {
|
|
|
|
- "type": "text",
|
|
|
|
- "term_vector": "with_positions_offsets"
|
|
|
|
- },
|
|
|
|
- "UpdateFrequency": {
|
|
|
|
- "type": "text",
|
|
|
|
- "term_vector": "with_positions_offsets"
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-}`
|
|
|
|
- EsCreateIndex(indexName, mappingJson)
|
|
|
|
-}
|
|
|
|
|
|
+//func CreateIndex() {
|
|
|
|
+// indexName := "cygx_article_v4" //utils.IndexName
|
|
|
|
+// mappingJson := `{
|
|
|
|
+// "mappings": {
|
|
|
|
+// "dynamic": true,
|
|
|
|
+// "properties": {
|
|
|
|
+// "ArticleId": {
|
|
|
|
+// "type": "integer"
|
|
|
|
+// },
|
|
|
|
+// "BodyText": {
|
|
|
|
+// "type": "text",
|
|
|
|
+// "term_vector": "with_positions_offsets",
|
|
|
|
+// "analyzer": "ik_smart"
|
|
|
|
+// },
|
|
|
|
+// "PublishDate": {
|
|
|
|
+// "type": "keyword"
|
|
|
|
+// },
|
|
|
|
+// "SubCategoryName": {
|
|
|
|
+// "type": "text",
|
|
|
|
+// "term_vector": "with_positions_offsets",
|
|
|
|
+// "analyzer": "ik_smart"
|
|
|
|
+// },
|
|
|
|
+// "Title": {
|
|
|
|
+// "type": "text",
|
|
|
|
+// "term_vector": "with_positions_offsets",
|
|
|
|
+// "analyzer": "ik_smart"
|
|
|
|
+// },
|
|
|
|
+// "TitleEn": {
|
|
|
|
+// "type": "text",
|
|
|
|
+// "term_vector": "with_positions_offsets"
|
|
|
|
+// },
|
|
|
|
+// "UpdateFrequency": {
|
|
|
|
+// "type": "text",
|
|
|
|
+// "term_vector": "with_positions_offsets"
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//}`
|
|
|
|
+// EsCreateIndex(indexName, mappingJson)
|
|
|
|
+//}
|
|
|
|
+//
|
|
|
|
+//func AddAllArticle() {
|
|
|
|
+// allList, err := models.GetArticleAll()
|
|
|
|
+// if err != nil {
|
|
|
|
+// fmt.Println("GetArticleAll Err:", err.Error())
|
|
|
|
+// return
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// indexName := "cygx_article_v4"
|
|
|
|
+//
|
|
|
|
+// for _, v := range allList {
|
|
|
|
+// content := html.UnescapeString(v.Body)
|
|
|
|
+// doc, err := goquery.NewDocumentFromReader(strings.NewReader(content))
|
|
|
|
+// if err != nil {
|
|
|
|
+// fmt.Println("create doc err:", err.Error())
|
|
|
|
+// return
|
|
|
|
+// }
|
|
|
|
+// bodyText := doc.Text()
|
|
|
|
+//
|
|
|
|
+// item := new(ElasticTestArticleDetail)
|
|
|
|
+// item.ArticleId = v.ArticleId
|
|
|
|
+// item.Title = v.Title
|
|
|
|
+// item.PublishDate = v.PublishDate
|
|
|
|
+// item.BodyText = bodyText
|
|
|
|
+// EsAddOrEditData(indexName, strconv.Itoa(v.ArticleId), item)
|
|
|
|
+// fmt.Println(v.ArticleId)
|
|
|
|
+// }
|
|
|
|
+//}
|
|
|
|
|
|
// "term_vector": "with_positions_offsets"
|
|
// "term_vector": "with_positions_offsets"
|
|
|
|
|