Documentation ¶
Index ¶
- func Init(conf Config)
- type Config
- type ESClient
- func (c *ESClient) Client() *elasticsearch.Client
- func (c *ESClient) Delete(index, docId string) (*esapi.Response, error)
- func (c *ESClient) DeleteByQuery(index []string, b []byte) (*esapi.Response, error)
- func (c *ESClient) Index(index, docId string, b []byte) (*esapi.Response, error)
- func (c *ESClient) IndexTemplateDel(name string) (*esapi.Response, error)
- func (c *ESClient) IndexTemplatePut(name string, b []byte) (*esapi.Response, error)
- func (c *ESClient) Loop(index []string, filter []goo_utils.M, fn func(p goo_utils.Params) error)
- func (c *ESClient) LoopV2(index []string, m goo_utils.M, fn func(p goo_utils.Params) error)
- func (c *ESClient) PageSearch(index []string, body []byte, fn func(p goo_utils.Params) error) error
- func (c *ESClient) Query(index []string, filter []goo_utils.M, offset, size int) (int64, []goo_utils.Params)
- func (c *ESClient) QueryV2(index []string, m goo_utils.M) (int64, []goo_utils.Params)
- func (c *ESClient) Search(index []string, body []byte) (*esapi.Response, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ESClient ¶ added in v1.1.76
type ESClient struct {
// contains filtered or unexported fields
}
func (*ESClient) DeleteByQuery ¶ added in v1.1.163
删除文档
func (*ESClient) IndexTemplateDel ¶ added in v1.1.163
删除索引模版
func (*ESClient) IndexTemplatePut ¶ added in v1.1.163
创建索引模版
- lifecycle.name: 生命周期策略 - number_of_shards: 索引分片数量 - number_of_replicas: 索引副本数量 - - nested: 嵌套对象 {list: [{id:1, name:”}]}
{ "index_patterns": ["abc-*"], "template": { "settings": { "number_of_shards": 3, "number_of_replicas": 0, "index.lifecycle.name": "90-days-default", "index.lifecycle.rollover_alias": "abc" }, "mappings": { "properties": { "id": {"type": "integer"}, "datetime": {"type": "date", "format": "yyyy-MM-dd HH:mm:ss"}, "name": {"type": "text"}, "list": { "type": "nested", "properties": { "id": {"type": "integer"}, "name": {"type": "text"}, } } } } } }
func (*ESClient) PageSearch ¶ added in v1.2.19
分页查询,用于大数量查询,普通查询,默认最多返回10000条
func (*ESClient) Search ¶ added in v1.1.163
搜索
- range: 范围搜索 - match: 匹配搜索 - match_phrase: 全文检索 - nested: 嵌套搜索 - inner_hits: 只返回匹配项 - inner_hits.size: 只返回匹配项的第1项 - highlight: 高亮 - _source.excludes: 不返回字段
GET /abd-*/_search
{ "from" : 0, "size" : 10, "query": { "bool": { "must": [ {"match": { "user_id": 2716 }}, {"range": { "datetime": { "gte": "2024-01-14 00:00:00", "lte": "2024-01-14 23:59:59" }}}, {"range": { "size": { "gte": 60, "lte": 3600 }}}, { "nested": { "path": "list", "query": { "match_phrase": { "list.title": "青岛" } }, "inner_hits": { "size": 1 } } } ] } }, "highlight": { "pre_tags": "<em>", "post_tags": "</em>", "fields": { "list.title": {} } }, "_source": { "excludes" : ["list"] } }
Click to show internal directories.
Click to hide internal directories.