protocol

package
v0.0.0-...-04d6450 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package protocol describes the core data structures and calling conventions of Tatris

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action map[string]*AliasTerm

type AggDateHistogram

type AggDateHistogram struct {
	Field            string      `json:"field"`             // only support date type
	Interval         string      `json:"interval"`          // combined interval field is deprecated since elasticsearch7.x
	FixedInterval    string      `json:"fixed_interval"`    // milliseconds (ms)/seconds (s)/minutes (m)/hours (h)/days (d)
	CalendarInterval string      `json:"calendar_interval"` // minute, 1m/hour, 1h/day, 1d/week, 1w/month, 1M/quarter, 1q/year, 1y
	TimeZone         string      `json:"time_zone"`         // +0100/+01:00, -0100/-01:00, UTC, Asia/Shanghai...
	MinDocCount      int         `json:"min_doc_count"`     // min_doc_count: 0, Zero filling
	Format           string      `json:"format"`            // TODO
	Offset           any         `json:"offset"`            // TODO
	Keyed            bool        `json:"keyed"`             // TODO
	Order            interface{} `json:"order"`             // TODO
	Missing          string      `json:"missing"`           // TODO
	// With extended_bounds setting, you now can "force" the histogram aggregation to start building
	// buckets on a specific min value and also keep on building buckets up to a max value (even if
	// there are no documents anymore). Using extended_bounds only makes sense when min_doc_count is
	// 0 (the empty buckets will never be returned if min_doc_count is greater than 0).
	ExtendedBounds *HistogramBound `json:"extended_bounds"`
	// The hard_bounds is a counterpart of extended_bounds and can limit the range of buckets in the
	// histogram. It is particularly useful in the case of open data ranges that can result in a
	// very large number of buckets.
	HardBounds *HistogramBound `json:"hard_bounds"`
}

type AggDateRange

type AggDateRange struct {
	Field    string      `json:"field"`
	TimeZone string      `json:"time_zone"`
	Ranges   []DateRange `json:"ranges"`
	Format   string      `json:"format"` // TODO
	Keyed    bool        `json:"keyed"`  // TODO
}

type AggHistogram

type AggHistogram struct {
	Field          string          `json:"field"` // only support numeric type
	Interval       float64         `json:"interval"`
	MinDocCount    int             `json:"min_doc_count"`
	Offset         float64         `json:"offset"`
	Keyed          bool            `json:"keyed"`   // TODO
	Order          interface{}     `json:"order"`   // TODO
	Missing        string          `json:"missing"` // TODO
	ExtendedBounds *HistogramBound `json:"extended_bounds"`
	HardBounds     *HistogramBound `json:"hard_bounds"`
}

type AggMetric

type AggMetric struct {
	Field string `json:"field"`
}

type AggNumericRange

type AggNumericRange struct {
	Field  string         `json:"field"`
	Ranges []NumericRange `json:"ranges"`
	Keyed  bool           `json:"keyed"`
}

type AggPercentiles

type AggPercentiles struct {
	Field    string    `json:"field"` // only support numeric type
	Percents []float64 `json:"percents"`
	// Approximate algorithms must balance memory utilization with estimation accuracy. This balance
	// can be controlled using a compression parameter
	Compression float64 `json:"compression"`
}

type AggTerms

type AggTerms struct {
	Field string `json:"field"`
	// This is to handle the case when one term has many documents on one shard but is just below
	// the size threshold on all other shards. If each shard only returned size terms, the
	// aggregation would return an partial doc count for the term. So terms returns more terms in an
	// attempt to catch the missing terms. This helps, but it’s still quite possible to return a
	// partial doc count for a term.
	// It just takes a term with more disparate per-shard doc counts.
	Size int `json:"size"` // default 10
	// increase shard_size to better account for these disparate doc counts and improve the accuracy
	// of the selection of top terms. It is much cheaper to increase the shard_size than to increase
	// the size. However, it still takes more bytes over the wire and
	// waiting in memory on the coordinating node.
	ShardSize int `json:"shard_size"` // default 5000
}

type AggWeightedAvg

type AggWeightedAvg struct {
	Value  *AggMetric `json:"value"`
	Weight *AggMetric `json:"weight"`
}

type Aggregation

type Aggregation struct {
	Value   interface{} `json:"value,omitempty"`
	Buckets []Bucket    `json:"buckets,omitempty"`
}

type Aggs

type Aggs struct {

	// Terms is a multi-bucket value source based aggregation where buckets are dynamically built -
	// one per unique value.
	// https://www.elastic.co/guide/en/elasticsearch/reference/8.6/search-aggregations-bucket-terms-aggregation.html
	Terms *AggTerms `json:"terms,omitempty"`
	// DateHistogram is similar to the normal Histogram, but it can only be used with date or date
	// range values.
	// https://www.elastic.co/guide/en/elasticsearch/reference/8.6/search-aggregations-bucket-datehistogram-aggregation.html
	DateHistogram *AggDateHistogram `json:"date_histogram,omitempty"`
	// Histogram is a multi-bucket values source based aggregation that can be applied on numeric
	// values or numeric range values extracted from the documents.
	// https://www.elastic.co/guide/en/elasticsearch/reference/8.6/search-aggregations-bucket-histogram-aggregation.html
	Histogram *AggHistogram `json:"histogram,omitempty"`
	// NumericRange is a multi-bucket value source based aggregation that enables the user to define
	// a set of ranges - each representing a bucket.
	// https://www.elastic.co/guide/en/elasticsearch/reference/8.6/search-aggregations-bucket-range-aggregation.html
	NumericRange *AggNumericRange `json:"range"`
	// DateRange is a range aggregation that is dedicated for date values.
	// https://www.elastic.co/guide/en/elasticsearch/reference/8.6/search-aggregations-bucket-daterange-aggregation.html
	DateRange *AggDateRange `json:"date_range"`
	// Filter is a single bucket aggregation that narrows the set of documents to those that match a
	// Query.
	// https://www.elastic.co/guide/en/elasticsearch/reference/8.6/search-aggregations-bucket-filter-aggregation.html
	Filter *Query `json:"filter"`
	// Count or ValueCount is a single-value metrics aggregation that counts the number of values
	// that are extracted from the aggregated documents.
	// https://www.elastic.co/guide/en/elasticsearch/reference/8.6/search-aggregations-metrics-valuecount-aggregation.html
	Count      *AggMetric `json:"count,omitempty"`
	ValueCount *AggMetric `json:"value_count,omitempty"`
	// Sum is a single-value metrics aggregation that sums up numeric values that are extracted from
	// the aggregated documents.
	// https://www.elastic.co/guide/en/elasticsearch/reference/8.6/search-aggregations-metrics-sum-aggregation.html
	Sum *AggMetric `json:"sum,omitempty"`
	// Min is a single-value metrics aggregation that keeps track and returns the minimum value
	// among numeric values extracted from the aggregated documents.
	// https://www.elastic.co/guide/en/elasticsearch/reference/8.6/search-aggregations-metrics-min-aggregation.html
	Min *AggMetric `json:"min,omitempty"`
	// Max is a single-value metrics aggregation that keeps track and returns the maximum value
	// among the numeric values extracted from the aggregated documents.
	// https://www.elastic.co/guide/en/elasticsearch/reference/8.6/search-aggregations-metrics-max-aggregation.html
	Max *AggMetric `json:"max,omitempty"`
	// Avg is a single-value metrics aggregation that computes the average of numeric values that
	// are extracted from the aggregated documents.
	// https://www.elastic.co/guide/en/elasticsearch/reference/8.6/search-aggregations-metrics-avg-aggregation.html
	Avg *AggMetric `json:"avg,omitempty"`
	// Cardinality is a single-value metrics aggregation that calculates an approximate count of
	// distinct values.
	// https://www.elastic.co/guide/en/elasticsearch/reference/8.6/search-aggregations-metrics-valuecount-aggregation.html
	Cardinality *AggMetric `json:"cardinality,omitempty"`
	// Percentiles is a multi-value metrics aggregation that calculates one or more percentiles over
	// numeric values extracted from the aggregated documents.
	// https://www.elastic.co/guide/en/elasticsearch/reference/8.6/search-aggregations-metrics-percentile-aggregation.html
	Percentiles *AggPercentiles `json:"percentiles,omitempty"`
	// WeightedAvg is a single-value metrics aggregation that computes the weighted average of
	// numeric values that are extracted from the aggregated documents.
	// https://www.elastic.co/guide/en/elasticsearch/reference/8.6/search-aggregations-metrics-weight-avg-aggregation.html
	WeightedAvg *AggWeightedAvg `json:"weighted_avg,omitempty"`
	// Aggs summarizes the data as metrics, statistics, or other analytics.
	Aggs map[string]Aggs `json:"aggs,omitempty"`
}

Aggs summarizes the data as metrics, statistics, or other analytics. https://www.elastic.co/guide/en/elasticsearch/reference/8.6/search-aggregations.html The JSON unmarshalling of Aggs is redefined in UnmarshalJSON.

func (*Aggs) UnmarshalJSON

func (q *Aggs) UnmarshalJSON(data []byte) error

type AliasGetResponse

type AliasGetResponse map[string]*Aliases

type AliasManageRequest

type AliasManageRequest struct {
	Actions []Action `json:"actions"`
}

type AliasTerm

type AliasTerm struct {
	Index string `json:"index,omitempty"`
	Alias string `json:"alias,omitempty"`
}

type Aliases

type Aliases struct {
	Aliases map[string]*AliasTerm `json:"aliases"`
}

type Bool

type Bool struct {
	Must               []*Query `json:"must,omitempty"`
	MustNot            []*Query `json:"must_not,omitempty"`
	Should             []*Query `json:"should,omitempty"`
	Filter             []*Query `json:"filter,omitempty"`
	MinimumShouldMatch string   `json:"minimum_should_match,omitempty"`
}

Bool matches documents matching boolean combinations of other queries. https://www.elastic.co/guide/en/elasticsearch/reference/8.6/query-dsl-bool-query.html

type Bucket

type Bucket map[string]interface{}

type BulkAction

type BulkAction map[string]*BulkMeta

type BulkMeta

type BulkMeta struct {
	Index string `json:"_index"`
	ID    string `json:"_id"`
}

type ClusterInfo

type ClusterInfo struct {
	Name        string `json:"name"`
	ClusterName string `json:"cluster_name"`
	ClusterUUID string `json:"cluster_uuid"`
	// version represents the elasticsearch version, we cannot modify the structure of
	// the returned body due to the need to be compatible with the elasticsearch client
	Version       VersionInfo `json:"version"`
	TatrisVersion VersionInfo `json:"tatris_version"`
	Tagline       string      `json:"tagline"`
}

type ClusterNode

type ClusterNode struct {
	Name          string `json:"name"`
	IP            string `json:"ip"`
	Host          string `json:"host"`
	Version       string `json:"version"`
	TatrisVersion string `json:"tatris_version"`
}

type ClusterNodes

type ClusterNodes map[string]ClusterNode

type ClusterNodesInfo

type ClusterNodesInfo struct {
	Nodes ClusterNodes `json:"nodes"`
}

type ClusterStatus

type ClusterStatus struct {
	ClusterName                 string  `json:"cluster_name"`
	Status                      string  `json:"status"`
	TimedOut                    bool    `json:"timed_out"`
	NumberOfNodes               int     `json:"number_of_nodes"`
	NumberOfDataNodes           int     `json:"number_of_data_nodes"`
	ActivePrimaryShards         int     `json:"active_primary_shards"`
	ActiveShards                int     `json:"active_shards"`
	RelocationShards            int     `json:"relocating_shards"`
	InitializingShards          int     `json:"initializing_shards"`
	UnassignedShards            int     `json:"unassigned_shards"`
	DelayedUnassignedShards     int     `json:"delayed_unassigned_shards"`
	NumberOfPendingTasks        int     `json:"number_of_pending_tasks"`
	NumberOfInFlightFetch       int     `json:"number_of_in_flight_fetch"`
	TaskMaxWaitingInQueueMills  int64   `json:"task_max_waiting_in_queue_millis"`
	ActiveShardsPercentAsNumber float64 `json:"active_shards_percent_as_number"`
}

type CreateIndexResponse

type CreateIndexResponse struct {
	*Response
	ShardsAcknowledged bool   `json:"shards_acknowledged,string,omitempty"`
	Index              string `json:"index,omitempty"`
}

type CreateIndexTemplateResponse

type CreateIndexTemplateResponse struct {
	Acknowledged bool `json:"acknowledged,string,omitempty"`
}

type DateRange

type DateRange struct {
	To   string `json:"to"`
	From string `json:"from"`
}

type Document

type Document map[string]any

type DynamicTemplate

type DynamicTemplate struct {
	Mapping          *DynamicTemplateMapping `json:"mapping"`
	MatchMappingType string                  `json:"match_mapping_type"`
	MatchPattern     string                  `json:"match_pattern"`
	Match            string                  `json:"match"`
	Unmatch          string                  `json:"unmatch"`
	// TODO: PathMatch and PathUnmatch will be enabled after nested types are supported
	PathMatch   string `json:"path_match"`
	PathUnmatch string `json:"path_unmatch"`
}

type DynamicTemplateMapping

type DynamicTemplateMapping struct {
	Type string `json:"type"`
}

type Err

type Err struct {
	Type         string `json:"type,omitempty"`
	Reason       string `json:"reason,omitempty"`
	ResourceType string `json:"resource.type,omitempty"`
	ResourceID   string `json:"resource.id,omitempty"`
	IndexUUID    string `json:"index_uuid,omitempty"`
	Index        string `json:"index,omitempty"`
}

type Error

type Error struct {
	*Err
	RootCause *Err `json:"root_cause,omitempty"`
}

type HistogramBound

type HistogramBound struct {
	Min float64 `json:"min"`
	Max float64 `json:"max"`
}

type Hit

type Hit struct {
	Index  string   `json:"_index"`
	ID     string   `json:"_id"`
	Source Document `json:"_source"`
	Score  float64  `json:"_score"`
	Type   string   `json:"_type"`
}

type Hits

type Hits struct {
	Total    Total   `json:"total"`
	Hits     []Hit   `json:"hits"`
	MaxScore float64 `json:"max_score"`
}

type Ids

type Ids struct {
	Values []string `json:"values"`
}

Ids returns documents based on their IDs. https://www.elastic.co/guide/en/elasticsearch/reference/8.6/query-dsl-ids-query.html

type Index

type Index struct {
	// index name
	Name string `json:"name"`
	// index settings
	Settings *Settings `json:"settings,omitempty"`
	// index mappings
	Mappings *Mappings `json:"mappings,omitempty"`
}

type IndexTemplate

type IndexTemplate struct {
	// Name of the index template.
	Name string `json:"name,omitempty"`
	// Priority to determine index template precedence when a new data stream or index is created.
	// The index template with the highest priority is chosen. If no priority is specified the
	// template is treated as though it is of priority 0 (the lowest priority).
	Priority int `json:"priority"`
	// IndexPatterns are used to match the names of indices during creation.
	IndexPatterns []string `json:"index_patterns"`
	// Template to be applied.
	Template *Template `json:"template"`
}

type IndexTemplateResponse

type IndexTemplateResponse struct {
	IndexTemplates []*IndexTemplateTerm `json:"index_templates"`
}

type IndexTemplateTerm

type IndexTemplateTerm struct {
	Name          string         `json:"name"`
	IndexTemplate *IndexTemplate `json:"index_template"`
}

type IngestItem

type IngestItem struct {
	Index       string `json:"_index"`
	Type        string `json:"_type"`
	ID          string `json:"_id"`
	Version     string `json:"_version"`
	Shards      Shards `json:"_shards"`
	SeqNo       int64  `json:"_seq_no"`
	PrimaryTerm int    `json:"_primary_term"`
}

type IngestRequest

type IngestRequest struct {
	Index     string     `json:"index"`
	Documents []Document `json:"documents"`
}

type IngestResponse

type IngestResponse struct {
	Took  int64         `json:"took,omitempty"`
	Error bool          `json:"error,omitempty"`
	Items []*IngestItem `json:"items,omitempty"`
}

type Mappings

type Mappings struct {
	// Mapping mode:
	// `true` means Tatris will define the field type dynamically, new fields are added to the
	// mapping (default).
	// `false` means new fields are ignored. These fields will not be indexed or
	// searchable, but will still appear in the _source field of returned hits. These fields will
	// not be added to the mapping, and new fields must be added explicitly.
	// `strict` means if new fields are detected, an exception is thrown and the document is
	// rejected. New fields must be explicitly added to the mapping.
	Dynamic string `json:"dynamic,omitempty"`
	// DynamicTemplates allow you greater control of how Tatris maps your data beyond the default
	// dynamic field mapping rules.
	// You enable dynamic mapping by setting the Dynamic mode to true or runtime.
	DynamicTemplates []map[string]*DynamicTemplate `json:"dynamic_templates,omitempty"`
	// Type mappings, object fields and nested fields contain subfields, called properties.
	Properties map[string]*Property `json:"properties,omitempty"`
}

Mappings is the process of defining how a document, and the fields it contains, are stored and indexed.

type Match

type Match map[string]interface{}

Match returns documents that match a provided text, number, date or boolean value. The provided text is analyzed before matching. https://www.elastic.co/guide/en/elasticsearch/reference/8.6/query-dsl-match-query.html

type MatchPhrase

type MatchPhrase map[string]interface{}

MatchPhrase analyzes the text and creates a phrase query out of the analyzed text. https://www.elastic.co/guide/en/elasticsearch/reference/8.6/query-dsl-match-query-phrase.html

type NumericRange

type NumericRange struct {
	To   float64 `json:"to"`
	From float64 `json:"from"`
}

type Property

type Property struct {
	// field data type
	Type string `json:"type,omitempty"`
	// field-level mapping mode
	Dynamic string `json:"dynamic,omitempty"`
}

type Query

type Query struct {
	// "match_all": {}
	MatchAll *MatchAll `json:"match_all,omitempty"`
	// {"match": {"field": "value"}}
	Match Match `json:"match,omitempty"`
	// {"match_phrase": {"field": "value"}}
	MatchPhrase MatchPhrase `json:"match_phrase,omitempty"`
	// {"query_string": {"query": "field:value"}}
	QueryString QueryString `json:"query_string,omitempty"`
	// {"ids": {"values": ["id1", "id2"]}}
	Ids *Ids `json:"ids,omitempty"`
	// {"term": {"field": "value"}}
	Term Term `json:"term,omitempty"`
	// {"terms": {"field": ["value1", "value2"]}}
	Terms Terms `json:"terms,omitempty"`
	// {"bool": {"must": [{"term": {"field1": "value1"}}, {"term": {"field2": "value2"}}]}}
	Bool *Bool `json:"bool,omitempty"`
	// {"range": {"field": {"gt": 10, "lt": 20}}}
	Range Range `json:"range,omitempty"`
}

Query describes how to search the document

type QueryRequest

type QueryRequest struct {
	Index string          `json:"index"`
	Query Query           `json:"query"`
	Aggs  map[string]Aggs `json:"aggs"`
	Sort  Sort            `json:"sort"`
	Size  int64           `json:"size"`
	From  int64           `json:"from"`
	// When the parameter typed_keys is true will be prefixing aggregation names with their type
	TypedKeys bool `json:"typed_keys"`
}

QueryRequest provides a full query DSL based on JSON to define queries. https://www.elastic.co/guide/en/elasticsearch/reference/8.6/query-dsl.html The JSON unmarshalling of QueryRequest is redefined in UnmarshalJSON.

func (*QueryRequest) UnmarshalJSON

func (q *QueryRequest) UnmarshalJSON(data []byte) error

type QueryResponse

type QueryResponse struct {
	Took         int64                  `json:"took"` // unit: ms
	TimedOut     bool                   `json:"timed_out"`
	Shards       Shards                 `json:"_shards"`
	Hits         Hits                   `json:"hits"`
	Error        interface{}            `json:"error,omitempty"`
	Status       int32                  `json:"status"`
	Aggregations map[string]Aggregation `json:"aggregations,omitempty"`
}

type QueryString

type QueryString map[string]interface{}

QueryString returns documents based on a provided query string, using a parser with a strict syntax. https://www.elastic.co/guide/en/elasticsearch/reference/8.6/query-dsl-query-string-query.html

type Range

type Range map[string]*RangeVal

Range returns documents that contain terms within a provided range. https://www.elastic.co/guide/en/elasticsearch/reference/8.6/query-dsl-range-query.html

type RangeVal

type RangeVal struct {
	Gt  interface{} `json:"gt,omitempty"`
	Gte interface{} `json:"gte,omitempty"`
	Lt  interface{} `json:"lt,omitempty"`
	Lte interface{} `json:"lte,omitempty"`
}

RangeVal describes a filter interval. https://www.elastic.co/guide/en/elasticsearch/reference/8.6/query-dsl-range-query.html The JSON unmarshalling of RangeVal is redefined in UnmarshalJSON.

func (*RangeVal) UnmarshalJSON

func (r *RangeVal) UnmarshalJSON(data []byte) error

type Response

type Response struct {
	Acknowledged bool   `json:"acknowledged,string,omitempty"`
	Error        *Error `json:"error,omitempty"`
}

type Settings

type Settings struct {
	// number of shards, default is 1
	NumberOfShards int `json:"number_of_shards,omitempty"`
	// number of replicas, default is 1 (ie one replica for each primary shard)
	NumberOfReplicas int `json:"number_of_replicas,omitempty"`
}

Settings contains index-level settings that can be set per-index. The JSON unmarshalling of Settings is redefined in UnmarshalJSON.

func (*Settings) UnmarshalJSON

func (s *Settings) UnmarshalJSON(data []byte) error

type Shards

type Shards struct {
	Total      int32 `json:"total"`
	Successful int32 `json:"successful"`
	Skipped    int32 `json:"skipped"`
	Failed     int32 `json:"failed"`
}

type Sort

type Sort []map[string]SortTerm

type SortTerm

type SortTerm struct {
	Order   string `json:"order"`
	Missing string `json:"missing"`
}

type Template

type Template struct {
	Settings *Settings             `json:"settings"`
	Mappings *Mappings             `json:"mappings"`
	Aliases  map[string]*AliasTerm `json:"aliases"`
}

type Term

type Term map[string]interface{}

Term returns documents that contain an exact term in a provided field. https://www.elastic.co/guide/en/elasticsearch/reference/8.6/query-dsl-term-query.html

type Terms

type Terms map[string]interface{}

Terms returns documents that contain one or more exact terms in a provided field. https://www.elastic.co/guide/en/elasticsearch/reference/8.6/query-dsl-terms-query.html

type Total

type Total struct {
	Value    int64  `json:"value"`
	Relation string `json:"relation"`
}

type VersionInfo

type VersionInfo struct {
	Number                    string `json:"number"`
	BuildFlavor               string `json:"build_flavor"`
	BuildHash                 string `json:"build_hash"`
	BuildDate                 string `json:"build_date"`
	BuildSnapshot             bool   `json:"build_snapshot"`
	MinimumWireVersion        string `json:"minimum_wire_version"`
	MinimumIndexCompatibility string `json:"minimum_index_compatibility"`
}

Jump to

Keyboard shortcuts

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