Documentation ¶
Index ¶
- func ExecuteEsSearch(ctx context.Context, client *elastic.Client, indexName string, ...) ([]byte, error)
- func GenerateBoolFilterQuery(filters []esquery.Mappable) *esquery.BoolQuery
- func GenerateBoolMustNotQuery(fieldName string, fieldValue interface{}) *esquery.BoolQuery
- func GenerateBoolShouldQuery(queries []esquery.Mappable) *esquery.BoolQuery
- func GenerateMatchAllQuery() *esquery.MatchAllQuery
- func GenerateMatchQuery(fieldName string, fieldValue interface{}) *esquery.MatchQuery
- func GenerateNestedQuery(path string, query esquery.Mappable) *esquery.CustomQueryMap
- func GenerateQueryStringQuery(fieldName string, fieldValue interface{}) *esquery.CustomQueryMap
- func GenerateRangeQueryGt(fieldName string, val interface{}) *esquery.RangeQuery
- func GenerateRangeQueryGte(fieldName string, val interface{}) *esquery.RangeQuery
- func GenerateRangeQueryLt(fieldName string, val interface{}) *esquery.RangeQuery
- func GenerateRangeQueryLte(fieldName string, val interface{}) *esquery.RangeQuery
- func GenerateRegexpQuery(fieldName string, fieldValue interface{}) *esquery.RegexpQuery
- func GenerateTermQuery(fieldName string, fieldValue interface{}) *esquery.TermQuery
- func GetIndexMapping() string
- func IndexPosts(ctx context.Context, client *elastic.Client, indexName string, posts []*Post)
- func NewESClient() (*elastic.Client, error)
- type AuthorBioData
- type AuthorStatData
- type Hits
- type InnerHit
- type Name
- type People
- type Post
- type SearchResult
- type Stat
- type Total
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteEsSearch ¶
func ExecuteEsSearch(ctx context.Context, client *elastic.Client, indexName string, query esquery.Mappable) ([]byte, error)
ExecuteEsSearch executes ES query.
func GenerateBoolFilterQuery ¶
GenerateBoolFilterQuery returns an ES Filter Bool Query.
func GenerateBoolMustNotQuery ¶
GenerateBoolMustNotQuery returns an ES Must Not Bool Query.
func GenerateBoolShouldQuery ¶
GenerateBoolShouldQuery returns an ES Should Bool Query.
func GenerateMatchAllQuery ¶
func GenerateMatchAllQuery() *esquery.MatchAllQuery
GenerateMatchAllQuery returns an ES MatchAll Query.
func GenerateMatchQuery ¶
func GenerateMatchQuery(fieldName string, fieldValue interface{}) *esquery.MatchQuery
GenerateMatchQuery returns an ES Match Query.
func GenerateNestedQuery ¶
func GenerateNestedQuery(path string, query esquery.Mappable) *esquery.CustomQueryMap
GenerateNestedQuery returns an ES Nested Query.
func GenerateQueryStringQuery ¶
func GenerateQueryStringQuery(fieldName string, fieldValue interface{}) *esquery.CustomQueryMap
GenerateQueryStringQuery returns an ES Query String Query.
func GenerateRangeQueryGt ¶
func GenerateRangeQueryGt(fieldName string, val interface{}) *esquery.RangeQuery
GenerateRangeQueryGt returns an ES Greater Than Range Query.
func GenerateRangeQueryGte ¶
func GenerateRangeQueryGte(fieldName string, val interface{}) *esquery.RangeQuery
GenerateRangeQueryGte returns an ES Greater Than or Equal Range Query.
func GenerateRangeQueryLt ¶
func GenerateRangeQueryLt(fieldName string, val interface{}) *esquery.RangeQuery
GenerateRangeQueryLt returns an ES Less Than Range Query.
func GenerateRangeQueryLte ¶
func GenerateRangeQueryLte(fieldName string, val interface{}) *esquery.RangeQuery
GenerateRangeQueryLte returns an ES Less Than or Equal Range Query.
func GenerateRegexpQuery ¶
func GenerateRegexpQuery(fieldName string, fieldValue interface{}) *esquery.RegexpQuery
GenerateRegexpQuery returns an ES Regexp Query.
func GenerateTermQuery ¶
GenerateTermQuery returns an ES Term Query.
func IndexPosts ¶
IndexPosts indexes posts to ES.
func NewESClient ¶
NewESClient returns an Elasticsearch client.
Types ¶
type AuthorBioData ¶
type AuthorBioData struct { Country string `json:"country"` State string `json:"state"` City string `json:"city"` }
AuthorBioData describes author's bio.
type AuthorStatData ¶
type AuthorStatData struct {
AuthorBio AuthorBioData `json:"authorbio"`
}
AuthorStatData decribes author's stat data.
type InnerHit ¶
type InnerHit struct {
Source Post `json:"_source"`
}
InnerHit is a single search result hit
type Post ¶
type Post struct { ID string `json:"id"` Author string `json:"author"` Message string `json:"message"` Department string `json:"department"` Email string `json:"email"` Clearance int `json:"clearance"` Action string `json:"action"` Resource string `json:"resource"` Conditions []map[string]string `json:"conditions"` Likes []map[string]string `json:"likes"` Followers []People `json:"followers"` Stats []Stat `json:"stats"` }
Post is a structure used for serializing/deserializing data in Elasticsearch.
func GetPrettyESResult ¶
GetPrettyESResult returns formatted ES results.
type SearchResult ¶
type SearchResult struct {
Hits Hits `json:"hits"`
}
SearchResult is Elasticsearch's search query result
type Stat ¶
type Stat struct {
AuthorStat AuthorStatData `json:"authorstat"`
}
Stat decribes author's stats.