Explorar o código

feat:增加返回值

wangchuanjin %!s(int64=2) %!d(string=hai) anos
pai
achega
494efc26fe
Modificáronse 2 ficheiros con 12 adicións e 0 borrados
  1. 6 0
      es/esv1.go
  2. 6 0
      es/esv7.go

+ 6 - 0
es/esv1.go

@@ -1261,6 +1261,12 @@ func (e *EsV1) GetAggs(index, itype, query string) (aggs Aggregations, count int
 					if parseErr == nil && hit.Highlight != nil && res[i] != nil {
 						res[i]["highlight"] = map[string][]string(hit.Highlight)
 					}
+					if hit.Source != nil && res[i] != nil {
+						data := map[string]interface{}{}
+						dataByte, _ := hit.Source.MarshalJSON()
+						json.Unmarshal(dataByte, &data)
+						res[i]["source"] = data
+					}
 				}
 			} else {
 				log.Println("查询结果太多,查询到:", resNum, "条")

+ 6 - 0
es/esv7.go

@@ -1056,6 +1056,12 @@ func (e *EsV7) GetAggs(index, itype, query string) (aggs Aggregations, count int
 					if parseErr == nil && hit.Highlight != nil && res[i] != nil {
 						res[i]["highlight"] = map[string][]string(hit.Highlight)
 					}
+					if hit.Source != nil && res[i] != nil {
+						data := map[string]interface{}{}
+						dataByte, _ := hit.Source.MarshalJSON()
+						json.Unmarshal(dataByte, &data)
+						res[i]["source"] = data
+					}
 				}
 			} else {
 				log.Println("查询结果太多,查询到:", resNum, "条")