es

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchPhraseQuery added in v1.3.0

func MatchPhraseQuery(name string, value interface{}) *elastic.MatchPhraseQuery

MatchPhraseQuery creates and initializes a new MatchPhraseQuery

func NewBoolQuery added in v1.3.0

func NewBoolQuery() *elastic.BoolQuery

NewBoolQuery creates a new bool query

func NewBoostingQuery added in v1.3.0

func NewBoostingQuery() *elastic.BoostingQuery

NewBoostingQuery creates a new boosting query

func NewBulkDeleteRequest added in v1.3.0

func NewBulkDeleteRequest() *elastic.BulkDeleteRequest

NewBulkDeleteRequest returns a new BulkDeleteRequest

func NewBulkIndexRequest added in v1.3.0

func NewBulkIndexRequest() *elastic.BulkIndexRequest

NewBulkIndexRequest returns a new BulkIndexRequest The operation type is "index" by default

func NewBulkUpdateRequest added in v1.3.0

func NewBulkUpdateRequest() *elastic.BulkUpdateRequest

NewBulkUpdateRequest returns a new BulkUpdateRequest

func NewConstantScoreQuery added in v1.3.0

func NewConstantScoreQuery(filter elastic.Query) *elastic.ConstantScoreQuery

NewConstantScoreQuery creates and initializes a new constant score query.

func NewDisMaxQuery added in v1.3.0

func NewDisMaxQuery() *elastic.DisMaxQuery

NewDisMaxQuery creates and initializes a new dis max query

func NewDistanceFeatureQuery added in v1.3.0

func NewDistanceFeatureQuery(field string, origin interface{}, pivot string) *elastic.DistanceFeatureQuery

NewDistanceFeatureQuery creates and initializes a new script_score query

func NewExistsQuery added in v1.3.0

func NewExistsQuery(name string) *elastic.ExistsQuery

NewExistsQuery creates and initializes a new exists query

func NewExponentialDecayFunction added in v1.3.0

func NewExponentialDecayFunction() *elastic.ExponentialDecayFunction

NewExponentialDecayFunction creates a new ExponentialDecayFunction

func NewFunctionScoreQuery added in v1.3.0

func NewFunctionScoreQuery() *elastic.FunctionScoreQuery

NewFunctionScoreQuery creates and initializes a new function score query

func NewFuzzyQuery added in v1.3.0

func NewFuzzyQuery(name string, value interface{}) *elastic.FuzzyQuery

NewFuzzyQuery creates a new fuzzy query

func NewHasChildQuery added in v1.3.0

func NewHasChildQuery(childType string, query elastic.Query) *elastic.HasChildQuery

NewHasChildQuery creates and initializes a new has_child query

func NewHasParentQuery added in v1.3.0

func NewHasParentQuery(parentType string, query elastic.Query) *elastic.HasParentQuery

NewHasParentQuery creates and initializes a new has_parent query

func NewHighlight added in v1.3.3

func NewHighlight(name string, value interface{}) *elastic.Highlight

NewHighlight creates a highlight instance

func NewMatchAllQuery added in v1.3.0

func NewMatchAllQuery() *elastic.MatchAllQuery

NewMatchAllQuery creates and initializes a new match all query

func NewMatchBoolPrefixQuery added in v1.3.0

func NewMatchBoolPrefixQuery(name string, queryText interface{}) *elastic.MatchBoolPrefixQuery

NewMatchBoolPrefixQuery creates and initializes a new MatchBoolPrefixQuery

func NewMatchNoneQuery added in v1.3.0

func NewMatchNoneQuery() *elastic.MatchNoneQuery

NewMatchNoneQuery creates and initializes a new match none query

func NewMatchPhrasePrefixQuery added in v1.3.0

func NewMatchPhrasePrefixQuery(name string, value interface{}) *elastic.MatchPhrasePrefixQuery

NewMatchPhrasePrefixQuery creates and initializes a new MatchPhrasePrefixQuery

func NewMatchQuery added in v1.3.0

func NewMatchQuery(name string, text interface{}) *elastic.MatchQuery

NewMatchQuery creates and initializes a new MatchQuery

func NewMultiMatchQuery added in v1.3.0

func NewMultiMatchQuery(text interface{}, fields ...string) *elastic.MultiMatchQuery

NewMultiMatchQuery creates and initializes a new MultiMatchQuery

func NewNestedQuery added in v1.3.0

func NewNestedQuery(path string, query elastic.Query) *elastic.NestedQuery

NewNestedQuery creates and initializes a new NestedQuery

func NewParentIdQuery added in v1.3.0

func NewParentIdQuery(typ, id string) *elastic.ParentIdQuery

NewParentIdQuery creates and initializes a new parent_id query

func NewPinnedQuery added in v1.3.0

func NewPinnedQuery() *elastic.PinnedQuery

NewPinnedQuery creates and initializes a new pinned query

func NewPrefixQuery added in v1.3.0

func NewPrefixQuery(name string, prefix string) *elastic.PrefixQuery

NewPrefixQuery creates and initializes a new PrefixQuery

func NewQueryStringQuery added in v1.3.0

func NewQueryStringQuery(queryString string) *elastic.QueryStringQuery

NewQueryStringQuery creates and initializes a new QueryStringQuery

func NewRangeQuery added in v1.3.0

func NewRangeQuery(name string) *elastic.RangeQuery

NewRangeQuery creates and initializes a new RangeQuery

func NewRawStringQuery added in v1.3.0

func NewRawStringQuery(q string) elastic.RawStringQuery

NewRawStringQuery initializes a new RawStringQuery It is the same as RawStringQuery(q).

func NewRegexpQuery added in v1.3.0

func NewRegexpQuery(name string, regexp string) *elastic.RegexpQuery

NewRegexpQuery creates and initializes a new RegexpQuery

func NewSearchRequest added in v1.3.0

func NewSearchRequest() *elastic.SearchRequest

NewSearchRequest creates a new search request

func NewSimpleQueryStringQuery added in v1.3.0

func NewSimpleQueryStringQuery(text string) *elastic.SimpleQueryStringQuery

NewSimpleQueryStringQuery creates and initializes a new SimpleQueryStringQuery

func NewSliceQuery added in v1.3.0

func NewSliceQuery() *elastic.SliceQuery

NewSliceQuery creates a new SliceQuery

func NewSpanFirstQuery added in v1.3.0

func NewSpanFirstQuery(query elastic.Query, end int) *elastic.SpanFirstQuery

NewSpanFirstQuery creates a new SpanFirstQuery

func NewSpanNearQuery added in v1.3.0

func NewSpanNearQuery(clauses ...elastic.Query) *elastic.SpanNearQuery

NewSpanNearQuery creates a new SpanNearQuery

func NewSpanTermQuery added in v1.3.0

func NewSpanTermQuery(field string, value ...interface{}) *elastic.SpanTermQuery

NewSpanTermQuery creates a new SpanTermQuery. When passing values, the first one is used to initialize the value

func NewTermQuery added in v1.3.0

func NewTermQuery(name string, value interface{}) *elastic.TermQuery

NewTermQuery creates and initializes a new TermQuery

func NewTermsQuery added in v1.3.0

func NewTermsQuery(name string, values ...interface{}) *elastic.TermsQuery

NewTermsQuery creates and initializes a new TermsQuery

func NewTermsSetQuery added in v1.3.0

func NewTermsSetQuery(name string, values ...interface{}) *elastic.TermsSetQuery

NewTermsSetQuery creates and initializes a new TermsSetQuery

func NewWildcardQuery added in v1.3.0

func NewWildcardQuery(name, wildcard string) *elastic.WildcardQuery

NewWildcardQuery creates and initializes a new WildcardQuery

func NewWrapperQuery added in v1.3.0

func NewWrapperQuery(source string) *elastic.WrapperQuery

NewWrapperQuery creates and initializes a new WrapperQuery

Types

type BoolQuery added in v1.3.3

type BoolQuery = elastic.BoolQuery

BoolQuery is an alias of elastic.BoolQuery

type Client added in v1.3.0

type Client struct {
	// contains filtered or unexported fields
}

Client es client struct

func NewClient

func NewClient(config *Config) *Client

NewClient returns es7 client instance

func (*Client) Count added in v1.3.0

func (c *Client) Count(ctx context.Context, index string, query es7.Query) (num int64, err error)

Count index documents

func (*Client) CreateDoc added in v1.3.0

func (c *Client) CreateDoc(ctx context.Context, index string, doc interface{}, docId ...string) (id string, err error)

CreateDoc insert a doc to index If don't assign a doc id, es will automatically generate one and assign it to _id

func (*Client) CreateDocs added in v1.3.0

func (c *Client) CreateDocs(ctx context.Context, index string, docs []interface{}, docIds ...string) (ids []string, err error)

CreateDocs batch insert a doc to index If don't assign a doc ids, es will automatically generate ids and assign them to _id separately

func (*Client) CreateIndex added in v1.3.0

func (c *Client) CreateIndex(ctx context.Context, index string, mapping string) (err error)

CreateIndex create an index

func (*Client) DeleteDoc added in v1.3.0

func (c *Client) DeleteDoc(ctx context.Context, index string, id string) (err error)

DeleteDoc delete doc by id

func (*Client) DeleteDocByQuery added in v1.3.0

func (c *Client) DeleteDocByQuery(ctx context.Context, index string, filter es7.Query) (num int64, err error)

DeleteDocByQuery delete doc by query

func (*Client) DeleteDocs added in v1.3.0

func (c *Client) DeleteDocs(ctx context.Context, index string, ids []string) (num int64, err error)

DeleteDocs batch delete docs by doc ids

func (*Client) DeleteIndex added in v1.3.0

func (c *Client) DeleteIndex(ctx context.Context, index string) (err error)

DeleteIndex delete an index

func (*Client) ExistIndex added in v1.3.0

func (c *Client) ExistIndex(ctx context.Context, index string) (exist bool, err error)

ExistIndex check if index exists

func (*Client) Flush added in v1.3.0

func (c *Client) Flush(ctx context.Context, indices ...string) (err error)

Flush asks Elasticsearch to free memory from the index and flush data to disk

func (*Client) GetDoc added in v1.3.0

func (c *Client) GetDoc(ctx context.Context, index string, id string, reply interface{}) (hit bool, err error)

GetDoc retrieve doc by id hit means doc exists or not when request success(return nil)

func (*Client) GetDocs added in v1.3.0

func (c *Client) GetDocs(ctx context.Context, index string, ids []string) (docs [][]byte, err error)

GetDocs retrieve docs by ids

func (*Client) NewBulk added in v1.3.0

func (c *Client) NewBulk() *es7.BulkService

NewBulk is the entry point to mass insert/update/delete documents

func (*Client) NewScroll added in v1.3.0

func (c *Client) NewScroll(index ...string) (search *es7.ScrollService)

NewScroll is the entry point for scroll searches

func (*Client) NewSearch added in v1.3.0

func (c *Client) NewSearch(index ...string) (search *es7.SearchService)

NewSearch is the entry point for searches

func (*Client) Ping added in v1.3.0

func (c *Client) Ping(ctx context.Context) (alive bool, err error)

Ping checks if an Elasticsearch server on a given URL is alive If the server responds with HTTP Status code 200 OK, the server is alive

func (*Client) Refresh added in v1.3.0

func (c *Client) Refresh(ctx context.Context, indices ...string) (err error)

Refresh asks Elasticsearch to refresh one or more indices

func (*Client) UpdateDoc added in v1.3.0

func (c *Client) UpdateDoc(ctx context.Context, index string, id string, doc interface{}) (err error)

UpdateDoc update a doc by id

func (*Client) UpdateDocs added in v1.3.0

func (c *Client) UpdateDocs(ctx context.Context, index string, ids []string, docs []interface{}) (num int64, err error)

UpdateDocs batch update docs

type Config

type Config struct {
	// Username es auth username
	Username string
	// Password es auth password
	Password string
	// Schema http/https, default http
	Schema string
	// URLs endpoint urls
	URLs []string
	// Plugins enabled plugins
	Plugins []string
	// Sniff enabled or disabled sniffer
	Sniff bool
}

Config client config

type SearchResult added in v1.3.3

type SearchResult = elastic.SearchResult

SearchResult is an alias of elastic.SearchResult

type Transport

type Transport struct {
	// contains filtered or unexported fields
}

Transport transport definition

func NewTransport

func NewTransport(config *Config) *Transport

NewTransport returns a Transport pointer

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (resp *http.Response, err error)

RoundTrip custom http RoundTrip Trace and metric request here and enable breaker at the same time

func (*Transport) SetRoundTripper

func (t *Transport) SetRoundTripper(rt http.RoundTripper) *Transport

SetRoundTripper set round tripper

Jump to

Keyboard shortcuts

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