Kaynağa Gözat

项目索引修改

maxiaoshan 5 yıl önce
ebeveyn
işleme
dd40162225
1 değiştirilmiş dosya ile 20 ekleme ve 0 silme
  1. 20 0
      udpcreateindex/src/projectindex.go

+ 20 - 0
udpcreateindex/src/projectindex.go

@@ -35,11 +35,30 @@ func projectTask(data []byte, mapInfo map[string]interface{}) {
 	var n int
 	i := 0
 	for tmp := make(map[string]interface{}); query.Next(tmp); i = i + 1 {
+		//不生索引字段
 		delete(tmp, "package")
 		delete(tmp, "winnerorder")
 		delete(tmp, "infofield")
 		delete(tmp, "budgettag")
 		delete(tmp, "bidamounttag")
+		list := tmp["list"].([]interface{})
+		for _, m := range list {
+			tmpM := m.(map[string]interface{})
+			if bidamount, ok := tmpM["bidamount"].(string); ok && len(bidamount) > 0 { //bidamount为string类型,转成float
+				tmpB := util.Float64All(tmpM["bidamount"])
+				tmpM["bidamount"] = tmpB
+			}
+			//projectscope截断
+			listProjectscopeRune := []rune(util.ObjToString(tmpM["projectscope"]))
+			if len(listProjectscopeRune) > 1000 {
+				tmpM["projectscope"] = string(listProjectscopeRune[:1000])
+			}
+		}
+		//projectscope截断
+		projectscopeRune := []rune(util.ObjToString(tmp["projectscope"]))
+		if len(projectscopeRune) > 1000 {
+			tmp["projectscope"] = string(projectscopeRune[:1000])
+		}
 		//		if s_budget := fmt.Sprint(tmp["budget"]); s_budget == "" || s_budget == "<nil>" || s_budget == "null" {
 		//			tmp["budget"] = nil
 		//		}
@@ -66,6 +85,7 @@ func projectTask(data []byte, mapInfo map[string]interface{}) {
 		}
 		tmp = make(map[string]interface{})
 	}
+
 	if i > 0 {
 		elastic.BulkSave(index, itype, &arr, true)
 	}