es

package
v0.0.0-...-547d54e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

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

func GenerateBoolFilterQuery(filters []esquery.Mappable) *esquery.BoolQuery

GenerateBoolFilterQuery returns an ES Filter Bool Query.

func GenerateBoolMustNotQuery

func GenerateBoolMustNotQuery(fieldName string, fieldValue interface{}) *esquery.BoolQuery

GenerateBoolMustNotQuery returns an ES Must Not Bool Query.

func GenerateBoolShouldQuery

func GenerateBoolShouldQuery(queries []esquery.Mappable) *esquery.BoolQuery

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

func GenerateTermQuery(fieldName string, fieldValue interface{}) *esquery.TermQuery

GenerateTermQuery returns an ES Term Query.

func GetIndexMapping

func GetIndexMapping() string

GetIndexMapping returns Elasticsearch mapping.

func IndexPosts

func IndexPosts(ctx context.Context, client *elastic.Client, indexName string, posts []*Post)

IndexPosts indexes posts to ES.

func NewESClient

func NewESClient() (*elastic.Client, error)

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 Hits

type Hits struct {
	Hits  []InnerHit `json:"hits"`
	Total Total      `json:"total"`
}

Hits are the search result hits + metadata like total hits number

type InnerHit

type InnerHit struct {
	Source Post `json:"_source"`
}

InnerHit is a single search result hit

type Name

type Name struct {
	First string `json:"first"`
	Last  string `json:"last"`
}

Name describes a person's first and last name.

type People

type People struct {
	Info Name `json:"info"`
}

People describes a person.

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

func GetPrettyESResult(searchResultBytes []byte) []Post

GetPrettyESResult returns formatted ES results.

func NewPost

func NewPost(id, author, message, department, email string, clearance int, action, resource string, conditions []map[string]string, likes []map[string]string, followers []People, stats []Stat) *Post

NewPost returns a post.

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.

type Total

type Total struct {
	Value int `json:"value"`
}

Total number of search result hits

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL