Documentation ¶
Index ¶
- type AggregateDsl
- func (d *AggregateDsl) Aggregates(aggs ...*AggregateDsl) *AggregateDsl
- func (d *AggregateDsl) Avg(field string) *AggregateDsl
- func (d *AggregateDsl) Cardinality(field string, rehash bool, threshold int) *AggregateDsl
- func (d *AggregateDsl) DateHistogram(field, interval string) *AggregateDsl
- func (d *AggregateDsl) ExtendedStats(field string) *AggregateDsl
- func (d *AggregateDsl) Filter(filters ...interface{}) *AggregateDsl
- func (d *AggregateDsl) Global() *AggregateDsl
- func (d *AggregateDsl) Histogram(field string, interval int) *AggregateDsl
- func (d *AggregateDsl) MarshalJSON() ([]byte, error)
- func (d *AggregateDsl) Max(field string) *AggregateDsl
- func (d *AggregateDsl) Min(field string) *AggregateDsl
- func (d *AggregateDsl) Missing(field string) *AggregateDsl
- func (d *AggregateDsl) Percentiles(field string) *AggregateDsl
- func (d *AggregateDsl) SignificantTerms(field string) *AggregateDsl
- func (d *AggregateDsl) Stats(field string) *AggregateDsl
- func (d *AggregateDsl) Sum(field string) *AggregateDsl
- func (d *AggregateDsl) Terms(field string) *AggregateDsl
- func (d *AggregateDsl) ValueCount(field string) *AggregateDsl
- type BoolClause
- type Cardinality
- type DateHistogram
- type FacetDsl
- type FieldAggregate
- type FilterClause
- type FilterOp
- func (f *FilterOp) Add(fop *FilterOp) *FilterOp
- func (f *FilterOp) Exists(name string) *FilterOp
- func (f *FilterOp) Field(fld string) *FilterOp
- func (f *FilterOp) From(from string) *FilterOp
- func (f *FilterOp) Gt(gt int) *FilterOp
- func (f *FilterOp) Missing(name string) *FilterOp
- func (f *FilterOp) Terms(field string, values ...interface{}) *FilterOp
- func (f *FilterOp) To(to string) *FilterOp
- type FilterWrap
- type Histogram
- type MatchAll
- type QueryDsl
- func (q *QueryDsl) All() *QueryDsl
- func (q *QueryDsl) Fields(fields, search, exists, missing string) *QueryDsl
- func (q *QueryDsl) Filter(f *FilterOp) *QueryDsl
- func (qd *QueryDsl) MarshalJSON() ([]byte, error)
- func (q *QueryDsl) Qs(qs *QueryString) *QueryDsl
- func (q *QueryDsl) Range(fop *FilterOp) *QueryDsl
- func (q *QueryDsl) Search(searchFor string) *QueryDsl
- func (q *QueryDsl) Term(name, value string) *QueryDsl
- type QueryEmbed
- type QueryString
- type QueryWrap
- type RangeDef
- type RangeDsl
- type RangeVal
- type SearchDsl
- func (s *SearchDsl) Aggregates(aggs ...*AggregateDsl) *SearchDsl
- func (s *SearchDsl) Bytes() ([]byte, error)
- func (s *SearchDsl) Facet(f *FacetDsl) *SearchDsl
- func (s *SearchDsl) Fields(fields ...string) *SearchDsl
- func (s *SearchDsl) Filter(fl ...interface{}) *SearchDsl
- func (s *SearchDsl) From(from string) *SearchDsl
- func (s *SearchDsl) Pretty() *SearchDsl
- func (s *SearchDsl) Query(q *QueryDsl) *SearchDsl
- func (s *SearchDsl) Result() (*core.SearchResult, error)
- func (s *SearchDsl) Scroll(duration string) *SearchDsl
- func (s *SearchDsl) Search(srch string) *SearchDsl
- func (s *SearchDsl) Size(size string) *SearchDsl
- func (s *SearchDsl) Sort(sort ...*SortDsl) *SearchDsl
- func (s *SearchDsl) Source(returnSource bool) *SearchDsl
- func (s *SearchDsl) Type(indexType string) *SearchDsl
- type SortBody
- type SortDsl
- type Term
- type Terms
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AggregateDsl ¶
type AggregateDsl struct { Name string TypeName string Type interface{} Filters *FilterWrap `json:"filters,omitempty"` AggregatesVal map[string]*AggregateDsl `json:"aggregations,omitempty"` }
func Aggregate ¶
func Aggregate(name string) *AggregateDsl
func (*AggregateDsl) Aggregates ¶
func (d *AggregateDsl) Aggregates(aggs ...*AggregateDsl) *AggregateDsl
*
- Aggregates accepts n "sub-aggregates" to be applied to this aggregate *
- agg := Aggregate("user").Term("user_id")
- agg.Aggregates(
- Aggregate("total_spent").Sum("price"),
- Aggregate("total_saved").Sum("discount"),
- )
func (*AggregateDsl) Avg ¶
func (d *AggregateDsl) Avg(field string) *AggregateDsl
func (*AggregateDsl) Cardinality ¶
func (d *AggregateDsl) Cardinality(field string, rehash bool, threshold int) *AggregateDsl
*
- Cardinality(
- "field_name",
- true,
- 0,
- )
func (*AggregateDsl) DateHistogram ¶
func (d *AggregateDsl) DateHistogram(field, interval string) *AggregateDsl
func (*AggregateDsl) ExtendedStats ¶
func (d *AggregateDsl) ExtendedStats(field string) *AggregateDsl
func (*AggregateDsl) Filter ¶
func (d *AggregateDsl) Filter(filters ...interface{}) *AggregateDsl
func (*AggregateDsl) Global ¶
func (d *AggregateDsl) Global() *AggregateDsl
func (*AggregateDsl) Histogram ¶
func (d *AggregateDsl) Histogram(field string, interval int) *AggregateDsl
func (*AggregateDsl) MarshalJSON ¶
func (d *AggregateDsl) MarshalJSON() ([]byte, error)
func (*AggregateDsl) Max ¶
func (d *AggregateDsl) Max(field string) *AggregateDsl
func (*AggregateDsl) Min ¶
func (d *AggregateDsl) Min(field string) *AggregateDsl
func (*AggregateDsl) Missing ¶
func (d *AggregateDsl) Missing(field string) *AggregateDsl
func (*AggregateDsl) Percentiles ¶
func (d *AggregateDsl) Percentiles(field string) *AggregateDsl
func (*AggregateDsl) SignificantTerms ¶
func (d *AggregateDsl) SignificantTerms(field string) *AggregateDsl
func (*AggregateDsl) Stats ¶
func (d *AggregateDsl) Stats(field string) *AggregateDsl
func (*AggregateDsl) Sum ¶
func (d *AggregateDsl) Sum(field string) *AggregateDsl
func (*AggregateDsl) Terms ¶
func (d *AggregateDsl) Terms(field string) *AggregateDsl
func (*AggregateDsl) ValueCount ¶
func (d *AggregateDsl) ValueCount(field string) *AggregateDsl
type Cardinality ¶
type DateHistogram ¶
type FacetDsl ¶
type FacetDsl struct { Terms map[string]*Term `json:"terms,omitempty"` Ranges map[string]*RangeDsl `json:"terms,omitempty"` // contains filtered or unexported fields }
func Facet ¶
func Facet() *FacetDsl
"facets": { "terms": { "terms": { "field": [ "@fields.category" ], "size": 25 } } }
"facets": { "actors": { "terms": {"field": ["actor"],"size": "10" }} , "langauge": { "terms": {"field": ["repository.language"],"size": "10" }} }
func (*FacetDsl) MarshalJSON ¶
type FieldAggregate ¶
type FieldAggregate struct {
Field string `json:"field"`
}
type FilterClause ¶
type FilterClause interface {
String() string
}
Filter clause is either a boolClause or FilterOp
type FilterOp ¶
type FilterOp struct { TermsMap map[string][]interface{} `json:"terms,omitempty"` Range map[string]map[string]interface{} `json:"range,omitempty"` Exist map[string]string `json:"exists,omitempty"` MisssingVal map[string]string `json:"missing,omitempty"` // contains filtered or unexported fields }
func Filter ¶
func Filter() *FilterOp
Filter Operation
Filter().Term("user","kimchy") // we use variadics to allow n arguments, first is the "field" rest are values Filter().Terms("user", "kimchy", "elasticsearch") Filter().Exists("repository.name")
func Range ¶
func Range() *FilterOp
A range is a special type of Filter operation
Range().Exists("repository.name")
type FilterWrap ¶
type FilterWrap struct {
// contains filtered or unexported fields
}
A wrapper to allow for custom serialization
func CompoundFilter ¶
func CompoundFilter(fl ...interface{}) *FilterWrap
func NewFilterWrap ¶
func NewFilterWrap() *FilterWrap
func (*FilterWrap) MarshalJSON ¶
func (f *FilterWrap) MarshalJSON() ([]byte, error)
Custom marshalling to support the query dsl
func (*FilterWrap) String ¶
func (f *FilterWrap) String() string
type QueryDsl ¶
type QueryDsl struct { QueryEmbed FilterVal *FilterOp `json:"filter,omitempty"` }
some ways to serialize
"query": { "filtered": { "query": { "query_string": { "default_operator": "OR", "default_field": "_all", "query": " actor:\"bob\" AND type:\"EventType\"" } }, "filter": { "range": { "@timestamp": { "from": "2012-12-29T16:52:48+00:00", "to": "2012-12-29T17:52:48+00:00" } } } } },
"query" : { "term" : { "user" : "kimchy" } }
"query" : { "match_all" : {} },
func (*QueryDsl) Fields ¶
Fields in query_string search
Fields("fieldname","search_for","","") Fields("fieldname,field2,field3","search_for","","") Fields("fieldname,field2,field3","search_for","field_exists","")
func (*QueryDsl) MarshalJSON ¶
MarshalJSON provides custom marshalling to support the query dsl which is a conditional json format, not always the same parent/children
type QueryEmbed ¶
type QueryEmbed struct { MatchAll *MatchAll `json:"match_all,omitempty"` Terms map[string]string `json:"term,omitempty"` Qs *QueryString `json:"query_string,omitempty"` }
The core Query Syntax can be embedded as a child of a variety of different parents
type QueryString ¶
type QueryString struct { DefaultOperator string `json:"default_operator,omitempty"` DefaultField string `json:"default_field,omitempty"` Query string `json:"query,omitempty"` Exists string `json:"_exists_,omitempty"` Missing string `json:"_missing_,omitempty"` Fields []string `json:"fields,omitempty"` }
type QueryWrap ¶
type QueryWrap struct {
Qs QueryString `json:"query_string,omitempty"`
}
should we reuse QueryDsl here?
type RangeDsl ¶
type RangeDsl struct { RangeDef *RangeDef `json:"range,omitempty"` FilterVal *FilterWrap `json:"facet_filter,omitempty"` }
func FacetRange ¶
type SearchDsl ¶
type SearchDsl struct { FromVal int `json:"from,omitempty"` SizeVal int `json:"size,omitempty"` Index string `json:"-"` FacetVal *FacetDsl `json:"facets,omitempty"` QueryVal *QueryDsl `json:"query,omitempty"` SortBody []*SortDsl `json:"sort,omitempty"` FilterVal *FilterWrap `json:"filter,omitempty"` AggregatesVal map[string]*AggregateDsl `json:"aggregations,omitempty"` // contains filtered or unexported fields }
func Search ¶
Search is the entry point to the SearchDsl, it is a chainable set of utilities to create searches.
params
@index = elasticsearch index to search out, err := Search("github").Type("Issues").Pretty().Query( Query().Range( Range().Field("created_at").From("2012-12-10T15:00:00-08:00").To("2012-12-10T15:10:00-08:00"), ).Search("add"), ).Result()
func (*SearchDsl) Aggregates ¶
func (s *SearchDsl) Aggregates(aggs ...*AggregateDsl) *SearchDsl
func (*SearchDsl) Facet ¶
Facet passes a Query expression to this search
qry := Search("github").Size("0").Facet( Facet().Regex("repository.name", "no.*").Size("8"), ) qry := Search("github").Pretty().Facet( Facet().Fields("type").Size("25"), )
func (*SearchDsl) Filter ¶
Filter adds a Filter Clause with optional Boolean Clause. This accepts n number of filter clauses. If more than one, and missing Boolean Clause it assumes "and"
qry := Search("github").Filter( Filter().Exists("repository.name"), ) qry := Search("github").Filter( "or", Filter().Exists("repository.name"), Filter().Terms("actor_attributes.location", "portland"), ) qry := Search("github").Filter( Filter().Exists("repository.name"), Filter().Terms("repository.has_wiki", true) )
type SortDsl ¶
func Sort ¶
SortDsl accepts any number of Sort commands
Query().Sort( Sort("last_name").Desc(), Sort("age"), )
func (*SortDsl) MarshalJSON ¶
type Term ¶
type Term struct { Terms Terms `json:"terms,omitempty"` FilterVal *FilterWrap `json:"facet_filter,omitempty"` }
Generic Term based (used in query, facet, filter)