Browse Source

feat:增加_id

wangchuanjin 2 years ago
parent
commit
9b0fbc33ff
2 changed files with 3 additions and 2 deletions
  1. 0 2
      es/es_test.go
  2. 3 0
      es/esv7.go

File diff suppressed because it is too large
+ 0 - 2
es/es_test.go


+ 3 - 0
es/esv7.go

@@ -1049,6 +1049,9 @@ func (e *EsV7) GetAggs(index, itype, query string) (aggs es.Aggregations, count
 				res = make([]map[string]interface{}, resNum)
 				res = make([]map[string]interface{}, resNum)
 				for i, hit := range searchResult.Hits.Hits {
 				for i, hit := range searchResult.Hits.Hits {
 					parseErr := json.Unmarshal(hit.Source, &res[i])
 					parseErr := json.Unmarshal(hit.Source, &res[i])
+					if res[i] != nil {
+						res[i]["_id"] = hit.Id
+					}
 					if parseErr == nil && hit.Highlight != nil && res[i] != nil {
 					if parseErr == nil && hit.Highlight != nil && res[i] != nil {
 						res[i]["highlight"] = map[string][]string(hit.Highlight)
 						res[i]["highlight"] = map[string][]string(hit.Highlight)
 					}
 					}

Some files were not shown because too many files changed in this diff