Documentation ¶
Index ¶
- type ESClient
- func (this *ESClient) BindRecords(container interface{})
- func (this *ESClient) GetAggregation() elastic.Aggregations
- func (this *ESClient) GetNestedSumAgg(nestedName, aggName string) float64
- func (this *ESClient) GetNestedSumAggWithFilter(nestedName, aggName string) float64
- func (this *ESClient) GetPageResult() vanilla.INextPageInfo
- func (this *ESClient) GetSearchRecords() []*elastic.SearchHit
- func (this *ESClient) GetSearchResult() *elastic.SearchResult
- func (this *ESClient) GetSumAgg(name string) float64
- func (this *ESClient) GetSumAggWithFilter(aggName string) float64
- func (this *ESClient) NoHits() *ESClient
- func (this *ESClient) Push(id string, data interface{})
- func (this *ESClient) Search(filters map[string]interface{}, args ...map[string]interface{}) *ESClient
- func (this *ESClient) Select(docType string) *ESClient
- func (this *ESClient) Update(data map[string]interface{}, filters map[string]interface{}) error
- func (this *ESClient) Use(indexName string) *ESClient
- func (this *ESClient) UseSyncUpdate(b bool) *ESClient
- type NamedAggregation
- type Query
- type QueryParser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ESClient ¶
type ESClient struct { vanilla.ServiceBase // contains filtered or unexported fields }
func NewESClient ¶
func (*ESClient) BindRecords ¶
func (this *ESClient) BindRecords(container interface{})
BindRecords 将搜索记录绑定到一个包含struct的slice中 container一定是某个slice的地址,如:
var orders []*Order es.BindRecords(&orders)
func (*ESClient) GetAggregation ¶
func (this *ESClient) GetAggregation() elastic.Aggregations
func (*ESClient) GetNestedSumAgg ¶
GetNestedSumAgg 嵌套聚合查询
func (*ESClient) GetNestedSumAggWithFilter ¶
GetNestedSumAggWithFilter 带filter的嵌套聚合查询
func (*ESClient) GetPageResult ¶
func (this *ESClient) GetPageResult() vanilla.INextPageInfo
func (*ESClient) GetSearchRecords ¶
func (*ESClient) GetSearchResult ¶
func (this *ESClient) GetSearchResult() *elastic.SearchResult
func (*ESClient) GetSumAggWithFilter ¶
GetSumAggWithFilter 带 filter 的聚合
func (*ESClient) Search ¶
func (this *ESClient) Search(filters map[string]interface{}, args ...map[string]interface{}) *ESClient
Search 查询 args: [pageInfo, sortAttrs, rawAggs, aggs]
func (*ESClient) UseSyncUpdate ¶
type NamedAggregation ¶
type NamedAggregation struct {
// contains filtered or unexported fields
}
NamedAggregation 供外部使用,可自由组合elastic提供的各类聚合
func NewNamedAggregation ¶
func NewNamedAggregation(name string, aggregation elastic.Aggregation) *NamedAggregation
func (*NamedAggregation) GetAggregation ¶
func (this *NamedAggregation) GetAggregation() elastic.Aggregation
func (*NamedAggregation) GetName ¶
func (this *NamedAggregation) GetName() string
type QueryParser ¶
type QueryParser struct { vanilla.ServiceBase // contains filtered or unexported fields }
将rest filter语法转换成es query语法、sort语法
func NewQueryParser ¶
func NewQueryParser() *QueryParser
func (*QueryParser) Parse ¶
func (this *QueryParser) Parse(filters map[string]interface{}) *Query
* 处理 [range, icontains, gte, lte, range, notin, not, in, gt, lt]
形如:{ 'bid': '1242464682341', 'createdAt__range': ['2018-07-08 12:12:22', '2018-07-09 13:12:22'], 'finalMoney__gte': 50, 'corp_name__contains': u'小', 'status__in': [1, 3], } ===>>> { 'bool': { 'must': [{ 'term': { 'bid': '1242464682341' } }, { 'range': { 'created_at': { 'gte': '2018-07-08 12:12:22', 'lte': '2018-07-09 13:12:22' } } }, { 'range': { 'final_money': { 'gte': 50 } } }, { 'match': { 'corp.name': u'小' } }, { 'terms': { 'status': [1, 3] } }] } }
Click to show internal directories.
Click to hide internal directories.