Browse Source

feat:修改es限制数量

wangchuanjin 2 years ago
parent
commit
aebed2c256
3 changed files with 13 additions and 13 deletions
  1. 5 5
      es/esv1.go
  2. 4 4
      es/esv7.go
  3. 4 4
      esv1/elasticutil.go

+ 5 - 5
es/esv1.go

@@ -160,7 +160,7 @@ func (e *EsV1) Get(index, itype, query string) *[]map[string]interface{} {
 
 		if searchResult.Hits != nil {
 			resNum := len(searchResult.Hits.Hits)
-			if resNum < 5000 {
+			if resNum <= 5000 {
 				res = make([]map[string]interface{}, resNum)
 				for i, hit := range searchResult.Hits.Hits {
 					//d := json.NewDecoder(bytes.NewBuffer(*hit.Source))
@@ -208,7 +208,7 @@ func (e *EsV1) GetOA(index, itype, query string) (*[]map[string]interface{}, int
 
 		if searchResult.Hits != nil {
 			resNum = len(searchResult.Hits.Hits)
-			if resNum < 5000 {
+			if resNum <= 5000 {
 				res = make([]map[string]interface{}, resNum)
 				for i, hit := range searchResult.Hits.Hits {
 					//d := json.NewDecoder(bytes.NewBuffer(*hit.Source))
@@ -444,7 +444,7 @@ func (e *EsV1) GetById(index, itype string, ids ...string) *[]map[string]interfa
 
 		if searchResult.Hits != nil {
 			resNum := len(searchResult.Hits.Hits)
-			if resNum < 5000 {
+			if resNum <= 5000 {
 				res = make([]map[string]interface{}, resNum)
 				for i, hit := range searchResult.Hits.Hits {
 					json.Unmarshal(*hit.Source, &res[i])
@@ -1217,7 +1217,7 @@ func (e *EsV1) GetWithCount(index, itype, query string) (int64, *[]map[string]in
 		if searchResult.Hits != nil {
 			resNum := len(searchResult.Hits.Hits)
 			count = searchResult.Hits.TotalHits
-			if resNum < 5000 {
+			if resNum <= 5000 {
 				res = make([]map[string]interface{}, resNum)
 				for i, hit := range searchResult.Hits.Hits {
 					//d := json.NewDecoder(bytes.NewBuffer(*hit.Source))
@@ -1256,7 +1256,7 @@ func (e *EsV1) GetAggs(index, itype, query string) (aggs esV7.Aggregations, coun
 		if searchResult.Hits != nil {
 			count = searchResult.Hits.TotalHits
 			resNum := len(searchResult.Hits.Hits)
-			if resNum < 5000 {
+			if resNum <= 5000 {
 				res = make([]map[string]interface{}, resNum)
 				for i, hit := range searchResult.Hits.Hits {
 					parseErr := json.Unmarshal(*hit.Source, &res[i])

+ 4 - 4
es/esv7.go

@@ -179,7 +179,7 @@ func (e *EsV7) get(index, itype, searchType, query string, isLimit, isHighlight
 		total = searchResult.TotalHits()
 		if searchResult.Hits != nil {
 			resNum = len(searchResult.Hits.Hits)
-			if isLimit && resNum < 5000 {
+			if isLimit && resNum <= 5000 {
 				res = make([]map[string]interface{}, resNum)
 				for i, hit := range searchResult.Hits.Hits {
 					//d := json.NewDecoder(bytes.NewBuffer(*hit.Source))
@@ -392,7 +392,7 @@ func (e *EsV7) GetById(index, itype string, ids ...string) *[]map[string]interfa
 
 		if searchResult.Hits != nil {
 			resNum := len(searchResult.Hits.Hits)
-			if resNum < 5000 {
+			if resNum <= 5000 {
 				res = make([]map[string]interface{}, resNum)
 				for i, hit := range searchResult.Hits.Hits {
 					json.Unmarshal(hit.Source, &res[i])
@@ -1008,7 +1008,7 @@ func (e *EsV7) GetWithCount(index, itype, query string) (int64, *[]map[string]in
 		count = searchResult.TotalHits()
 		if searchResult.Hits != nil {
 			resNum := len(searchResult.Hits.Hits)
-			if resNum < 5000 {
+			if resNum <= 5000 {
 				res = make([]map[string]interface{}, resNum)
 				for i, hit := range searchResult.Hits.Hits {
 					//d := json.NewDecoder(bytes.NewBuffer(*hit.Source))
@@ -1047,7 +1047,7 @@ func (e *EsV7) GetAggs(index, itype, query string) (aggs es.Aggregations, count
 		}
 		if searchResult.Hits != nil {
 			resNum := len(searchResult.Hits.Hits)
-			if resNum < 5000 {
+			if resNum <= 5000 {
 				res = make([]map[string]interface{}, resNum)
 				for i, hit := range searchResult.Hits.Hits {
 					parseErr := json.Unmarshal(hit.Source, &res[i])

+ 4 - 4
esv1/elasticutil.go

@@ -191,7 +191,7 @@ func Get(index, itype, query string) *[]map[string]interface{} {
 
 		if searchResult.Hits != nil {
 			resNum := len(searchResult.Hits.Hits)
-			if resNum < 5000 {
+			if resNum <= 5000 {
 				res = make([]map[string]interface{}, resNum)
 				for i, hit := range searchResult.Hits.Hits {
 					//d := json.NewDecoder(bytes.NewBuffer(*hit.Source))
@@ -244,7 +244,7 @@ func GetNew(index, itype, query string) (*[]map[string]interface{}, int64) {
 		if searchResult.Hits != nil {
 			count = searchResult.Hits.TotalHits
 			resNum := len(searchResult.Hits.Hits)
-			if resNum < 5000 {
+			if resNum > 5000 {
 				log.Println("查询结果太多,查询到:", resNum, "条")
 			} else {
 				res = make([]map[string]interface{}, resNum)
@@ -290,7 +290,7 @@ func GetOA(index, itype, query string) (*[]map[string]interface{}, int) {
 
 		if searchResult.Hits != nil {
 			resNum = len(searchResult.Hits.Hits)
-			if resNum < 5000 {
+			if resNum <= 5000 {
 				res = make([]map[string]interface{}, resNum)
 				for i, hit := range searchResult.Hits.Hits {
 					//d := json.NewDecoder(bytes.NewBuffer(*hit.Source))
@@ -528,7 +528,7 @@ func GetById(index, itype string, ids ...string) *[]map[string]interface{} {
 
 		if searchResult.Hits != nil {
 			resNum := len(searchResult.Hits.Hits)
-			if resNum < 5000 {
+			if resNum <= 5000 {
 				res = make([]map[string]interface{}, resNum)
 				for i, hit := range searchResult.Hits.Hits {
 					json.Unmarshal(*hit.Source, &res[i])