esutil

package
v0.8.8 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: Apache-2.0 Imports: 18 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreatePageToken added in v0.6.1

func CreatePageToken(pit string, from int) string

func DecodeResponse

func DecodeResponse(r io.ReadCloser, i interface{}) error

func EncodeRequest

func EncodeRequest(body interface{}) (io.Reader, string)

func ParsePageToken added in v0.6.1

func ParsePageToken(pageToken string) (string, int, error)

func ReadRequestBody

func ReadRequestBody(request *http.Request, target interface{})

Types

type BulkRequest added in v0.8.0

type BulkRequest struct {
	Index   string
	Refresh string // TODO: use RefreshOption type
	Items   []*BulkRequestItem
}

type BulkRequestItem added in v0.8.0

type BulkRequestItem struct {
	Message    proto.Message
	DocumentId string
	Join       *EsJoin
	Operation  EsBulkOperation
	Routing    string
}

type Client added in v0.6.3

type Client interface {
	Create(ctx context.Context, request *CreateRequest) (string, error)
	Bulk(ctx context.Context, request *BulkRequest) (*EsBulkResponse, error)
	Search(ctx context.Context, request *SearchRequest) (*SearchResponse, error)
	MultiSearch(ctx context.Context, request *MultiSearchRequest) (*EsMultiSearchResponse, error)
	Get(ctx context.Context, request *GetRequest) (*EsGetResponse, error)
	MultiGet(ctx context.Context, request *MultiGetRequest) (*EsMultiGetResponse, error)
	Update(ctx context.Context, request *UpdateRequest) (*EsIndexDocResponse, error)
	Delete(ctx context.Context, request *DeleteRequest) error
}

func NewClient added in v0.6.3

func NewClient(logger *zap.Logger, esClient *elasticsearch.Client) Client

type CreateRequest added in v0.6.3

type CreateRequest struct {
	Index      string
	Refresh    string // TODO: use RefreshOption type
	Message    proto.Message
	DocumentId string
	Join       *EsJoin
}

type DeleteRequest added in v0.6.3

type DeleteRequest struct {
	Index   string
	Search  *EsSearch
	Refresh string // TODO: use RefreshOption type
	Routing string
}

type ESPitResponse added in v0.6.1

type ESPitResponse struct {
	Id string `json:"id"`
}

type EsBulkOperation added in v0.8.0

type EsBulkOperation string
const (
	BULK_INDEX  EsBulkOperation = "INDEX"
	BULK_CREATE EsBulkOperation = "CREATE"
)

type EsBulkQueryFragment added in v0.6.0

type EsBulkQueryFragment struct {
	Index  *EsBulkQueryOperationFragment `json:"index,omitempty"`
	Create *EsBulkQueryOperationFragment `json:"create,omitempty"`
}

type EsBulkQueryOperationFragment added in v0.8.0

type EsBulkQueryOperationFragment struct {
	Id      string `json:"_id,omitempty"`
	Index   string `json:"_index,omitempty"`
	Routing string `json:"routing,omitempty"`
}

type EsBulkResponse added in v0.6.0

type EsBulkResponse struct {
	Items  []*EsBulkResponseItem `json:"items"`
	Errors bool
}

type EsBulkResponseItem added in v0.6.0

type EsBulkResponseItem struct {
	Index  *EsIndexDocResponse `json:"index,omitempty"`
	Create *EsIndexDocResponse `json:"create,omitempty"`
}

type EsDeleteResponse added in v0.6.0

type EsDeleteResponse struct {
	Took                 int           `json:"took"`
	TimedOut             bool          `json:"timed_out"`
	Total                int           `json:"total"`
	Deleted              int           `json:"deleted"`
	Batches              int           `json:"batches"`
	VersionConflicts     int           `json:"version_conflicts"`
	Noops                int           `json:"noops"`
	ThrottledMillis      int           `json:"throttled_millis"`
	RequestsPerSecond    float64       `json:"requests_per_second"`
	ThrottledUntilMillis int           `json:"throttled_until_millis"`
	Failures             []interface{} `json:"failures"`
}

type EsDocWithJoin added in v0.8.0

type EsDocWithJoin struct {
	Join    *EsJoin
	Message proto.Message
}

EsDocWithJoin makes it possible to add a "join" field to the source JSON without having to modify the underlying protobuf message. The "join" field is used as described here: https://www.elastic.co/guide/en/elasticsearch/reference/7.10/parent-join.html. When marshaled to JSON, the "join" field will be merged with the protobuf JSON as a patch.

func (*EsDocWithJoin) MarshalJSON added in v0.8.0

func (e *EsDocWithJoin) MarshalJSON() ([]byte, error)

type EsGetResponse added in v0.7.0

type EsGetResponse struct {
	Id     string          `json:"_id"`
	Found  bool            `json:"found"`
	Source json.RawMessage `json:"_source"`
}

type EsIndexDocError added in v0.6.0

type EsIndexDocError struct {
	Type   string `json:"type"`
	Reason string `json:"reason"`
}

type EsIndexDocResponse added in v0.6.0

type EsIndexDocResponse struct {
	Id      string           `json:"_id"`
	Result  string           `json:"result"`
	Version int              `json:"_version"`
	Status  int              `json:"status"`
	Error   *EsIndexDocError `json:"error,omitempty"`
}

type EsIndexResponse added in v0.6.1

type EsIndexResponse struct {
	Acknowledged       bool   `json:"acknowledged"`
	ShardsAcknowledged bool   `json:"shards_acknowledged"`
	Index              string `json:"index"`
}

response for index creation

type EsJoin added in v0.8.0

type EsJoin struct {
	// Field represents the name of the join field
	Field string
	// Name represents the name of the document, as specified within the index mapping
	Name string
	// Parent represents the ID of this resource's parent. Omit this if this document has no parent.
	Parent string
}

type EsMultiGetItem added in v0.8.2

type EsMultiGetItem struct {
	Id      string `json:"_id"`
	Index   string `json:"_index,omitempty"`
	Routing string `json:"routing,omitempty"`
}

type EsMultiGetRequest added in v0.6.1

type EsMultiGetRequest struct {
	IDs  []string          `json:"ids,omitempty"`
	Docs []*EsMultiGetItem `json:"docs,omitempty"`
}

type EsMultiGetResponse added in v0.6.1

type EsMultiGetResponse struct {
	Docs []*EsGetResponse `json:"docs"`
}

type EsMultiSearchQueryFragment added in v0.6.0

type EsMultiSearchQueryFragment struct {
	Index   string `json:"index"`
	Routing string `json:"routing,omitempty"`
}

type EsMultiSearchResponse added in v0.6.0

type EsMultiSearchResponse struct {
	Responses []*EsMultiSearchResponseHitsSummary `json:"responses"`
}

type EsMultiSearchResponseHit added in v0.6.0

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

type EsMultiSearchResponseHits added in v0.6.0

type EsMultiSearchResponseHits struct {
	Total *EsSearchResponseTotal      `json:"total"`
	Hits  []*EsMultiSearchResponseHit `json:"hits"`
}

type EsMultiSearchResponseHitsSummary added in v0.6.0

type EsMultiSearchResponseHitsSummary struct {
	Hits *EsMultiSearchResponseHits `json:"hits"`
}

type EsSearch added in v0.6.0

type EsSearch struct {
	Query    *filtering.Query       `json:"query,omitempty"`
	Sort     map[string]EsSortOrder `json:"sort,omitempty"`
	Collapse *EsSearchCollapse      `json:"collapse,omitempty"`
	Pit      *EsSearchPit           `json:"pit,omitempty"`
	Routing  string                 `json:"-"`
}

type EsSearchCollapse added in v0.6.1

type EsSearchCollapse struct {
	Field string `json:"field,omitempty"`
}

type EsSearchPit added in v0.6.1

type EsSearchPit struct {
	Id        string `json:"id"`
	KeepAlive string `json:"keep_alive"`
}

type EsSearchResponse added in v0.6.0

type EsSearchResponse struct {
	Took  int                   `json:"took"`
	Hits  *EsSearchResponseHits `json:"hits"`
	PitId string                `json:"pit_id"`
}

type EsSearchResponseHit added in v0.6.0

type EsSearchResponseHit struct {
	ID         string          `json:"_id"`
	Source     json.RawMessage `json:"_source"`
	Highlights json.RawMessage `json:"highlight"`
	Sort       []interface{}   `json:"sort"`
}

type EsSearchResponseHits added in v0.6.0

type EsSearchResponseHits struct {
	Total *EsSearchResponseTotal `json:"total"`
	Hits  []*EsSearchResponseHit `json:"hits"`
}

type EsSearchResponseTotal added in v0.6.0

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

type EsSortOrder added in v0.6.0

type EsSortOrder string
const (
	EsSortOrderAscending  EsSortOrder = "asc"
	EsSortOrderDescending EsSortOrder = "desc"
)

type GetRequest added in v0.7.0

type GetRequest struct {
	Index      string
	DocumentId string
	Routing    string
}

type MockEsTransport

type MockEsTransport struct {
	ReceivedHttpRequests  []*http.Request
	PreparedHttpResponses []*http.Response
	Actions               []TransportAction
}

func (*MockEsTransport) Perform

func (m *MockEsTransport) Perform(req *http.Request) (*http.Response, error)

type MultiGetRequest added in v0.6.3

type MultiGetRequest struct {
	Index       string
	DocumentIds []string
	Items       []*EsMultiGetItem
}

type MultiSearchRequest added in v0.6.3

type MultiSearchRequest struct {
	Index    string
	Searches []*EsSearch
}

type SearchPaginationOptions added in v0.6.3

type SearchPaginationOptions struct {
	Size      int
	Token     string
	Keepalive string
}

type SearchRequest added in v0.6.3

type SearchRequest struct {
	Index      string
	Search     *EsSearch
	Pagination *SearchPaginationOptions
}

type SearchResponse added in v0.6.3

type SearchResponse struct {
	Hits          *EsSearchResponseHits
	NextPageToken string
}

type TransportAction

type TransportAction = func(req *http.Request) (*http.Response, error)

type UpdateRequest added in v0.6.3

type UpdateRequest struct {
	Index      string
	DocumentId string
	Refresh    string // TODO: use RefreshOption type
	Message    proto.Message
	Routing    string
}

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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