2 Star 0 Fork 0

TeamsHub/backend-gopkg

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
elastic.go 2.46 KB
一键复制 编辑 原始数据 按行查看 历史
wuzheng0709 提交于 2024-08-04 18:48 . fix mod
package elastic
import "github.com/olivere/elastic"
var Client *elastic.Client
type SearchResult elastic.SearchResult
//func init() {
// elastic_host := "http://" + config.C.Elastic.Host + ":" + config.C.Elastic.Port
// elastic_user := config.C.Elastic.User
// elastic_password := config.C.Elastic.Password
// var sniff = false //<4>
// cfg := &esconfig.Config{
// URL: elastic_host,
// Username: elastic_user,
// Password: elastic_password,
// }
//
// cfg.Sniff = &sniff
// Client, _ = elastic.NewClientFromConfig(cfg)
//}
// 精确查询
func NewBoolQuery() *elastic.BoolQuery {
return elastic.NewBoolQuery()
}
func NewMatchQuery(name string, text interface{}) *elastic.MatchQuery {
return elastic.NewMatchQuery(name, text)
}
func NewMatchPhraseQuery(name string, value interface{}) *elastic.MatchPhraseQuery {
return elastic.NewMatchPhraseQuery(name, value)
}
func NewQueryStringQuery(queryString string) *elastic.QueryStringQuery {
return elastic.NewQueryStringQuery(queryString)
}
func NewWildcardQuery(name string, wildcard string) *elastic.WildcardQuery {
return elastic.NewWildcardQuery(name, wildcard)
}
func NewTermQuery(name string, value interface{}) *elastic.TermQuery {
return elastic.NewTermQuery(name, value)
}
func NewTermsQuery(name string, value ...interface{}) *elastic.TermsQuery {
return elastic.NewTermsQuery(name, value...)
}
// 范围查询
func NewRangeQuery(name string) *elastic.RangeQuery {
return elastic.NewRangeQuery(name)
}
func NewDateRangeAggregation() *elastic.DateRangeAggregation {
return elastic.NewDateRangeAggregation()
}
// 模糊查询
func NewFuzzyQuery(name string, value interface{}) *elastic.FuzzyQuery {
return elastic.NewFuzzyQuery(name, value)
}
// 通过多个字段查询
func NewMultiMatchQuery(text interface{}, field ...string) *elastic.MultiMatchQuery {
return elastic.NewMultiMatchQuery(text, field...)
}
func NewHasChildQuery(childType string, query elastic.Query) *elastic.HasChildQuery {
return elastic.NewHasChildQuery(childType, query)
}
func NewHasParentQuery(parentType string, query elastic.Query) *elastic.HasParentQuery {
return elastic.NewHasParentQuery(parentType, query)
}
func NewFilterAggregation() *elastic.FilterAggregation {
return elastic.NewFilterAggregation()
}
func NewScriptQuery(script string) *elastic.ScriptQuery {
esscript := elastic.NewScript(script)
return elastic.NewScriptQuery(esscript)
}
func NewExistsQuery(name string) *elastic.ExistsQuery {
return elastic.NewExistsQuery(name)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wuzheng0709/backend-gopkg.git
git@gitee.com:wuzheng0709/backend-gopkg.git
wuzheng0709
backend-gopkg
backend-gopkg
v1.5.23

搜索帮助