xuzhiheng пре 2 година
родитељ
комит
b1814e45ce
1 измењених фајлова са 8 додато и 8 уклоњено
  1. 8 8
      src/util/utiltag.go

+ 8 - 8
src/util/utiltag.go

@@ -111,7 +111,7 @@ func UtilEsFind1(tags map[string]interface{}, dataType string) (error, string, i
 	if strings.Contains(esquery, "site") { //选择网站名称,使用全量数据索引
 		index = EsAllIndex
 	}
-	dataTypes, esquery2 := "", ""
+	dataTypes := ""
 	if dataType == "1" {
 		index = InterimIndex
 		dataTypes = "1"
@@ -120,16 +120,15 @@ func UtilEsFind1(tags map[string]interface{}, dataType string) (error, string, i
 		log.Println("esquery111111", esquery)
 		esquery, _ = FilterTimeSql(esquery, startTime, endTime)
 		log.Println("esquery222222", esquery)
-		esquery2 = esquery
 	} else {
 		index = TotalIndex
 		dataTypes = "2"
 	}
 	// esquery = esquery[:len(esquery)-1] + `,"size":` + fmt.Sprintf("%d", i_maxnum) + `}`
 	log.Println("esquery", esquery)
-	err, counts := searchDataArr(index, esquery, esquery2, sdataid, i_maxnum, tags, maths)
+	err, counts := searchDataArr(index, esquery, sdataid, i_maxnum, tags, maths)
 	if counts == 0 && err == nil && index == InterimIndex {
-		err, counts = searchDataArr(TotalIndex, esquery, esquery2, sdataid, i_maxnum, tags, maths)
+		err, counts = searchDataArr(TotalIndex, esquery, sdataid, i_maxnum, tags, maths)
 		if counts > 0 {
 			dataTypes = "2"
 		}
@@ -137,7 +136,7 @@ func UtilEsFind1(tags map[string]interface{}, dataType string) (error, string, i
 	return err, dataTypes, counts
 }
 
-func searchDataArr(index, esquery, esquery2, sdataid string, i_maxnum int64, tags map[string]interface{}, maths []map[string]string) (error, int64) {
+func searchDataArr(index, esquery, sdataid string, i_maxnum int64, tags map[string]interface{}, maths []map[string]string) (error, int64) {
 	var (
 		err    error
 		counts = int64(0)
@@ -147,7 +146,7 @@ func searchDataArr(index, esquery, esquery2, sdataid string, i_maxnum int64, tag
 		listLen := int(redis.LLEN("datag", "jyqyfw_es_query"))
 		if listLen < 5 {
 			redis.RPUSH("datag", "jyqyfw_es_query", 1)
-			err, counts = searchData(index, esquery, esquery2, sdataid, i_maxnum, tags, maths)
+			err, counts = searchData(index, esquery, sdataid, i_maxnum, tags, maths)
 			redis.LPOP("datag", "jyqyfw_es_query")
 			break
 		} else if listLen > 20 || times > 60 {
@@ -170,7 +169,7 @@ func (m *MySource) Source() (interface{}, error) {
 	return mp["query"], nil
 }
 
-func searchData(index, esquery, esquery2, sdataid string, i_maxnum int64, tags map[string]interface{}, maths []map[string]string) (error, int64) {
+func searchData(index, esquery, sdataid string, i_maxnum int64, tags map[string]interface{}, maths []map[string]string) (error, int64) {
 	esCon := elastic.VarEs.(*elastic.EsV7)
 	client := esCon.GetEsConn()
 	defer esCon.DestoryEsConn(client)
@@ -273,7 +272,8 @@ func searchData(index, esquery, esquery2, sdataid string, i_maxnum int64, tags m
 				datas = append(datas, item)
 			}
 		}
-		counts := Es.Count(index, Itype, esquery2)
+		counts := Es.Count(index, Itype, esquery)
+		log.Println("esCount查询的数据量 ", counts)
 		Mgo.Update("cuserdepartrule", bson.M{"_id": tags["_id"]}, bson.M{
 			"$set": bson.M{
 				"i_estotal": counts,