es

package
v0.0.0-...-f5bfad9 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewElasticsearch7Client

func NewElasticsearch7Client(config ClientConfig, roundTripper http.RoundTripper) (*es7client, error)

Types

type AggregationResponse

type AggregationResponse struct {
	Buckets []struct {
		Key string `json:"key"`
	} `json:"buckets"`
}

type BoolQuery

type BoolQuery struct {
	Term         map[string]string             `json:"term,omitempty"`
	Regexp       map[string]TermQuery          `json:"regexp,omitempty"`
	Nested       *NestedQuery                  `json:"nested,omitempty"`
	BoolQuery    map[BoolQueryType][]BoolQuery `json:"bool,omitempty"`
	RangeQueries map[string]RangeQuery         `json:"range,omitempty"`
	MatchQueries map[string]MatchQuery         `json:"match,omitempty"`
}

type BoolQueryType

type BoolQueryType string
const Must BoolQueryType = "must"

Must defines must bool query type.

const Should BoolQueryType = "should"

Should defines should bool query type.

type BulkIndexResponse

type BulkIndexResponse struct {
	ID     string `json:"_id"`
	Result string `json:"result"`
	Status int    `json:"status"`
	Error  struct {
		Type   string `json:"type"`
		Reason string `json:"reason"`
		Cause  struct {
			Type   string `json:"type"`
			Reason string `json:"reason"`
		} `json:"caused_by"`
	} `json:"error"`
}

type BulkResponse

type BulkResponse struct {
	Errors bool               `json:"errors"`
	Items  []BulkResponseItem `json:"items"`
}

type BulkResponseItem

type BulkResponseItem struct {
	Index BulkIndexResponse `json:"index"`
}

type ClientConfig

type ClientConfig struct {
	Addresses []string
	Username  string
	Password  string
}

type ElasticsearchClient

type ElasticsearchClient interface {
	Search(ctx context.Context, query SearchBody, size int, indices ...string) (*SearchResponse, error)
}

type Hit

type Hit struct {
	Source *json.RawMessage `json:"_source"`
}

type Hits

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

type MatchQuery

type MatchQuery struct {
	Query string `json:"query"`
}

type NestedQuery

type NestedQuery struct {
	Path  string `json:"path"`
	Query Query  `json:"query"`
}

type Order

type Order string
const (
	AscOrder Order = "asc"
)

type Query

type Query struct {
	Term         *Terms                        `json:"term,omitempty"`
	RangeQueries map[string]RangeQuery         `json:"range,omitempty"`
	BoolQuery    map[BoolQueryType][]BoolQuery `json:"bool,omitempty"`
}

type RangeQuery

type RangeQuery struct {
	GTE interface{} `json:gte`
	LTE interface{} `json:lte`
}

type SearchBody

type SearchBody struct {
	Indices        []string           `json:"-"`
	Aggregations   json.RawMessage    `json:"aggs,omitempty"`
	Query          *Query             `json:"query,omitempty"`
	Sort           []map[string]Order `json:"sort,omitempty"`
	Size           int                `json:"size"`
	TerminateAfter int                `json:"terminate,omitempty"`
	SearchAfter    []interface{}      `json:"search_after,omitempty"`
}

type SearchResponse

type SearchResponse struct {
	Hits  Hits                           `json:"hits"`
	Aggs  map[string]AggregationResponse `json:"aggregations,omitempty"`
	Error *SearchResponseError           `json:"error,omitempty"`
}

type SearchResponseError

type SearchResponseError struct {
	json.RawMessage
}

type TermQuery

type TermQuery struct {
	Value string `json:"value"`
}

type Terms

type Terms map[string]TermQuery

Jump to

Keyboard shortcuts

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