|
@@ -195,40 +195,40 @@ func (e *Elastic) DelById(index, itype, id string) bool {
|
|
return b
|
|
return b
|
|
}
|
|
}
|
|
|
|
|
|
-//func (e *Elastic) GetNoLimit(index, itype, query string) *[]map[string]interface{} {
|
|
|
|
-// //log.Println("query -- ", query)
|
|
|
|
-// client := e.GetEsConn()
|
|
|
|
-// defer e.DestoryEsConn(client)
|
|
|
|
-// var res []map[string]interface{}
|
|
|
|
-// if client != nil {
|
|
|
|
-// defer func() {
|
|
|
|
-// if r := recover(); r != nil {
|
|
|
|
-// log.Println("[E]", r)
|
|
|
|
-// for skip := 1; ; skip++ {
|
|
|
|
-// _, file, line, ok := runtime.Caller(skip)
|
|
|
|
-// if !ok {
|
|
|
|
-// break
|
|
|
|
-// }
|
|
|
|
-// go log.Printf("%v,%v\n", file, line)
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }()
|
|
|
|
-// searchResult, err := client.Search().Index(index).Source(query).Do(context.Background())
|
|
|
|
-// if err != nil {
|
|
|
|
-// log.Println("从ES查询出错", err.Error())
|
|
|
|
-// return nil
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// if searchResult.Hits != nil {
|
|
|
|
-// resNum := len(searchResult.Hits.Hits)
|
|
|
|
-// res = make([]map[string]interface{}, resNum)
|
|
|
|
-// for i, hit := range searchResult.Hits.Hits {
|
|
|
|
-// json.Unmarshal(*hit.Source, &res[i])
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// return &res
|
|
|
|
-//}
|
|
|
|
|
|
+func (e *Elastic) GetNoLimit(index, query string) *[]map[string]interface{} {
|
|
|
|
+ client := e.GetEsConn()
|
|
|
|
+ defer e.DestoryEsConn(client)
|
|
|
|
+ var res []map[string]interface{}
|
|
|
|
+ if client != nil {
|
|
|
|
+ defer func() {
|
|
|
|
+ if r := recover(); r != nil {
|
|
|
|
+ log.Println("[E]", r)
|
|
|
|
+ for skip := 1; ; skip++ {
|
|
|
|
+ _, file, line, ok := runtime.Caller(skip)
|
|
|
|
+ if !ok {
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ go log.Printf("%v,%v\n", file, line)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }()
|
|
|
|
+ searchResult, err := client.Search().Index(index).Source(query).Do(context.Background())
|
|
|
|
+ if err != nil {
|
|
|
|
+ log.Println("从ES查询出错", err.Error())
|
|
|
|
+ return nil
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if searchResult.Hits != nil {
|
|
|
|
+ resNum := len(searchResult.Hits.Hits)
|
|
|
|
+ util.Debug(resNum)
|
|
|
|
+ res = make([]map[string]interface{}, resNum)
|
|
|
|
+ for i, hit := range searchResult.Hits.Hits {
|
|
|
|
+ json.Unmarshal(hit.Source, &res[i])
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return &res
|
|
|
|
+}
|
|
|
|
|
|
//func (e *Elastic) GetByIdField(index, itype, id, fields string) *map[string]interface{} {
|
|
//func (e *Elastic) GetByIdField(index, itype, id, fields string) *map[string]interface{} {
|
|
// client := e.GetEsConn()
|
|
// client := e.GetEsConn()
|