|
@@ -183,8 +183,8 @@ func Save(index, itype string, obj interface{}) bool {
|
|
|
//{"query":{"filtered":{"query":{"match_all":{}},"filter":{"range":{"balance":{"gte":20000,"lte":30000}}}}}}
|
|
|
//{"query":{"match_all":{}},"from":10,"size":10,"_source":["account_number","balance"],"sort":{"balance":{"order":"desc"}}}
|
|
|
//{"query":{"match_phrase":{"address":"milllane"}}}和match不同会去匹配整个短语,相当于must[]
|
|
|
-func DfsGet(index, query string) (int64, *[]map[string]interface{}) {
|
|
|
- t, _, l := get(index, "", query, "dfs_query_then_fetch", true, true)
|
|
|
+func GetBySearchType(index, searchType, query string) (int64, *[]map[string]interface{}) {
|
|
|
+ t, _, l := get(index, "", searchType, query, true, true)
|
|
|
return t, l
|
|
|
}
|
|
|
func Get(index, itype, query string) *[]map[string]interface{} {
|
|
@@ -213,7 +213,11 @@ func get(index, itype, query, searchType string, isLimit, isHighlight bool) (int
|
|
|
}
|
|
|
}
|
|
|
}()
|
|
|
- searchResult, err := client.Search().Index(index).Source(query).Do(context.TODO())
|
|
|
+ ss := client.Search().Index(index).Source(query)
|
|
|
+ if searchType != "" {
|
|
|
+ ss.SearchType(searchType)
|
|
|
+ }
|
|
|
+ searchResult, err := ss.Do(context.TODO())
|
|
|
if err != nil {
|
|
|
log.Println("从ES查询出错", err.Error())
|
|
|
return total, resNum, nil
|