builder

package
v4.6.3 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: MIT Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildEsSearch

func BuildEsSearch(esExec *elasticsearchv6.EsExecutor, esSearch *EsSearch) (*elastic.SearchService, error)

BuildEsSearch builds a backend elasticsearchv6 query definition

func BuildEsSearchFromSource

func BuildEsSearchFromSource(esExec *elasticsearchv6.EsExecutor, esSearch *EsSearch) (*elastic.SearchService, error)

BuildEsSearchFromSource builds a backend elasticsearchv6 query definition for advanced source fact definition

func ContextualizeDatePlaceholders

func ContextualizeDatePlaceholders(query string, t time.Time) string

ContextualizeDatePlaceholders contextualize a query with the standard date placeholders (now, begin, timezone) @Deprecated

func ContextualizePlaceholders

func ContextualizePlaceholders(query string, placeholders map[string]string) string

ContextualizePlaceholders contextualize a query with an ensemble of placeholders (__placeholder__) @Deprecated

func ContextualizeTimeZonePlaceholders

func ContextualizeTimeZonePlaceholders(query string, t time.Time) string

ContextualizeTimeZonePlaceholders replaces timezone placeholder for old fact version @Deprecated

Types

type Aggregation

type Aggregation interface {
	GetName() string
	AggSource() elastic.Aggregation
}

Aggregation is an interface for every type of elasticsearch aggregation

type AvgAgg

type AvgAgg struct {
	Type   string `json:"type"`
	Name   string `json:"name"`
	Field  string `json:"field"`
	Script bool   `json:"script"`
}

AvgAgg represent an average aggregation definition

func (*AvgAgg) AggSource

func (agg *AvgAgg) AggSource() elastic.Aggregation

AggSource returns a standard elasticsearch aggregation

func (*AvgAgg) GetName

func (agg *AvgAgg) GetName() string

GetName returns the agg name

type BoolQuery

type BoolQuery struct {
	Type    string  `json:"type"`
	Filter  []Query `json:"filter,omitempty"`
	Must    []Query `json:"must,omitempty"`
	Should  []Query `json:"should,omitempty"`
	MustNot []Query `json:"mustNot,omitempty"`
}

BoolQuery represents an elasticsearch bool query clause

func (*BoolQuery) Contextualize

func (q *BoolQuery) Contextualize(key string, value string)

Contextualize contextualize the current query filter with key-value system

func (*BoolQuery) Source

func (q *BoolQuery) Source() elastic.Query

Source convert the query to a elasticsearch query interface

func (*BoolQuery) UnmarshalJSON

func (q *BoolQuery) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshal a bool query interface content

type Calendar

type Calendar struct {
	Scope      string       `json:"scope"`
	Thresholds []Thresholds `json:"thresholds"`
}

Calendar constains the thresholds for a scope

type CardinalityAgg

type CardinalityAgg struct {
	Type   string `json:"type"`
	Name   string `json:"name"`
	Field  string `json:"field"`
	Script bool   `json:"script"`
}

CardinalityAgg represent a cardinality aggregation definition

func (*CardinalityAgg) AggSource

func (agg *CardinalityAgg) AggSource() elastic.Aggregation

AggSource returns a standard elasticsearch aggregation

func (*CardinalityAgg) GetName

func (agg *CardinalityAgg) GetName() string

GetName returns the agg name

type DateHistogramAgg

type DateHistogramAgg struct {
	Type     string        `json:"type"`
	Name     string        `json:"name"`
	Field    string        `json:"field"`
	Interval string        `json:"interval"`
	SubAggs  []Aggregation `json:"aggs"`
	TimeZone string        `json:"timezone,omitempty"`
}

DateHistogramAgg represent a datehistogram aggregation definition

func (*DateHistogramAgg) AggSource

func (agg *DateHistogramAgg) AggSource() elastic.Aggregation

AggSource returns a standard elasticsearch aggregation

func (*DateHistogramAgg) GetName

func (agg *DateHistogramAgg) GetName() string

GetName returns the agg name

func (*DateHistogramAgg) UnmarshalJSON

func (agg *DateHistogramAgg) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshal a json byte slice in a DateHistogramAgg

type EsQuery

type EsQuery struct {
	Alias      string    `json:"alias,omitempty"`
	Evaluation *Calendar `json:"evaluation,omitempty"`
	ID         int64     `json:"id,omitempty"`
	Name       string    `json:"name,omitempty"`
	Search     *EsSearch `json:"search"`
}

EsQuery is related directly to one KPI

func NewEsQuery

func NewEsQuery(alias string, id int64, search *EsSearch, evaluation *Calendar, name string) *EsQuery

NewEsQuery build and returns a pointer to a new EsQuery

type EsSearch

type EsSearch struct {
	Indices []string      `json:"indices"`
	Size    int           `json:"size"`
	Offset  int           `json:"offset"`
	Order   bool          `json:"order"`
	Query   Query         `json:"query,omitempty"`
	Aggs    []Aggregation `json:"aggs,omitempty"`
	Source  string        `json:"source,omitempty"`
}

EsSearch represents a search definition

func (*EsSearch) UnmarshalJSON

func (es *EsSearch) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshal a json byte slice in an EsSearch object

type ExistsQuery

type ExistsQuery struct {
	Type  string `json:"type"`
	Field string `json:"field"`
}

ExistsQuery represents an elasticsearch exists query clause

func (*ExistsQuery) Contextualize

func (q *ExistsQuery) Contextualize(key string, value string)

Contextualize contextualize the current query filter with key-value system

func (*ExistsQuery) Source

func (q *ExistsQuery) Source() elastic.Query

Source convert the query to a elasticsearch query interface

type FieldSort

type FieldSort struct {
	Field string `json:"field"`
	Order string `json:"order" enums:"asc,desc"`
}

FieldSort is a specific sorting method using a sorting field

func NewFieldSort

func NewFieldSort(field string, order string) FieldSort

NewFieldSort returns a new FieldSort based a on field and an order (asc, desc)

func (FieldSort) Source

func (s FieldSort) Source() elastic.Sorter

Source returns an elastic sorter

type FilterAgg

type FilterAgg struct {
	Name    string       `json:"name"`
	SubAggs *Aggregation `json:"aggs"`
	Query   *Query       `json:"filter"`
}

FilterAgg represent a filter aggregation definition

func (*FilterAgg) AggSource

func (agg *FilterAgg) AggSource() elastic.Aggregation

AggSource returns a standard elasticsearch aggregation

func (*FilterAgg) GetName

func (agg *FilterAgg) GetName() string

GetName returns the agg name

type HistogramAgg

type HistogramAgg struct {
	Type     string        `json:"type"`
	Name     string        `json:"name"`
	Field    string        `json:"field"`
	Interval float64       `json:"interval"`
	SubAggs  []Aggregation `json:"aggs"`
}

HistogramAgg represent an histogram aggregation definition

func (*HistogramAgg) AggSource

func (agg *HistogramAgg) AggSource() elastic.Aggregation

AggSource returns a standard elasticsearch aggregation

func (*HistogramAgg) GetName

func (agg *HistogramAgg) GetName() string

GetName returns the agg name

func (*HistogramAgg) UnmarshalJSON

func (agg *HistogramAgg) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshal a json byte slice in a HistogramAgg

type MaxAgg

type MaxAgg struct {
	Type   string `json:"type"`
	Name   string `json:"name"`
	Field  string `json:"field"`
	Script bool   `json:"script"`
}

MaxAgg represent a max aggregation definition

func (*MaxAgg) AggSource

func (agg *MaxAgg) AggSource() elastic.Aggregation

AggSource returns a standard elasticsearch aggregation

func (*MaxAgg) GetName

func (agg *MaxAgg) GetName() string

GetName returns the agg name

type MinAgg

type MinAgg struct {
	Type   string `json:"type"`
	Name   string `json:"name"`
	Field  string `json:"field"`
	Script bool   `json:"script"`
}

MinAgg represent a min aggregation definition

func (*MinAgg) AggSource

func (agg *MinAgg) AggSource() elastic.Aggregation

AggSource returns a standard elasticsearch aggregation

func (*MinAgg) GetName

func (agg *MinAgg) GetName() string

GetName returns the agg name

type Query

type Query interface {
	Source() elastic.Query
	Contextualize(key string, value string)
}

Query is an interface for all parts of an elasticsearch query clause

type QuerySourceJSON

type QuerySourceJSON struct {
	Size  int         `json:"size"`
	From  int         `json:"from"`
	Sort  interface{} `json:"sort,omitempty"`
	Query interface{} `json:"query,omitempty"`
	Aggs  interface{} `json:"aggs,string,omitempty"`
}

QuerySourceJSON query and agg elastic syntax ready.

func BuildEsSearchSource

func BuildEsSearchSource(esSearch *EsSearch) (*QuerySourceJSON, error)

BuildEsSearchSource returns a json representation of an elasticsearchv6 query clause

func NewQuerySourceJSON

func NewQuerySourceJSON(query interface{}, aggs interface{}, size int, from int, sort interface{}) *QuerySourceJSON

NewQuerySourceJSON builds QuerySourceJSON.

type RangeQuery

type RangeQuery struct {
	Type        string      `json:"type"`
	Field       string      `json:"field"`
	From        interface{} `json:"from,omitempty"`
	IncludeFrom bool        `json:"includeFrom"`
	To          interface{} `json:"to,omitempty"`
	IncludeTo   bool        `json:"includeTo"`
	TimeZone    string      `json:"timezone,omitempty"`
}

RangeQuery represents an elasticsearch range query clause

func (*RangeQuery) Contextualize

func (q *RangeQuery) Contextualize(key string, value string)

Contextualize contextualize the current query filter with key-value system

func (*RangeQuery) Source

func (q *RangeQuery) Source() elastic.Query

Source convert the query to a elasticsearch query interface

type RegexpQuery added in v4.4.6

type RegexpQuery struct {
	Type  string      `json:"type"`
	Field string      `json:"field"`
	Value interface{} `json:"value"`
}

func (*RegexpQuery) Contextualize added in v4.4.6

func (q *RegexpQuery) Contextualize(key string, value string)

Contextualize contextualize the current query filter with key-value system

func (*RegexpQuery) Source added in v4.4.6

func (q *RegexpQuery) Source() elastic.Query

type ScriptQuery

type ScriptQuery struct {
	Type   string `json:"type"`
	Script string `json:"script"`
}

ScriptQuery represents an elasticsearch script query clause

func (*ScriptQuery) Contextualize

func (q *ScriptQuery) Contextualize(key string, value string)

Contextualize contextualize the current query filter with key-value system

func (*ScriptQuery) Source

func (q *ScriptQuery) Source() elastic.Query

Source convert the query to a elasticsearch query interface

type SortByDoc

type SortByDoc struct{}

SortByDoc is a default sorting method (by document index)

func NewSortByDoc

func NewSortByDoc() SortByDoc

NewSortByDoc returns a new default SortByDoc

func (SortByDoc) Source

func (s SortByDoc) Source() elastic.Sorter

Source returns an elastic sorter

type SourceAgg

type SourceAgg struct {
	Aggregation
}

SourceAgg represent a source aggregation definition

type SumAgg

type SumAgg struct {
	Type   string `json:"type"`
	Name   string `json:"name"`
	Field  string `json:"field"`
	Script bool   `json:"script"`
}

SumAgg represent a sum aggregation definition

func (*SumAgg) AggSource

func (agg *SumAgg) AggSource() elastic.Aggregation

AggSource returns a standard elasticsearch aggregation

func (*SumAgg) GetName

func (agg *SumAgg) GetName() string

GetName returns the agg name

type TermAgg

type TermAgg struct {
	Type    string        `json:"type"`
	Name    string        `json:"name"`
	Field   string        `json:"field"`
	Size    int           `json:"size"`
	SubAggs []Aggregation `json:"aggs"`
}

TermAgg represent a term aggregation definition

func (*TermAgg) AggSource

func (agg *TermAgg) AggSource() elastic.Aggregation

AggSource returns a standard elasticsearch aggregation

func (*TermAgg) GetName

func (agg *TermAgg) GetName() string

GetName returns the agg name

func (*TermAgg) UnmarshalJSON

func (agg *TermAgg) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshal a json byte slice in a TermAgg

type TermQuery

type TermQuery struct {
	Type  string      `json:"type"`
	Field string      `json:"field"`
	Value interface{} `json:"value"`
}

TermQuery represents an elasticsearch term query clause

func (*TermQuery) Contextualize

func (q *TermQuery) Contextualize(key string, value string)

Contextualize contextualize the current query filter with key-value system

func (*TermQuery) Source

func (q *TermQuery) Source() elastic.Query

Source convert the query to a elasticsearch query interface

type Threshold

type Threshold struct {
	From string             `json:"from"`
	To   string             `json:"to"`
	Val  []ThresholdContent `json:"value"`
}

Threshold type. @Deprecated

type ThresholdContent

type ThresholdContent struct {
	ID   int         `json:"id,omitempty"`
	From interface{} `json:"from"`
	To   interface{} `json:"to"`
	Name string      `json:"name"`
}

ThresholdContent type value.

type Thresholds

type Thresholds struct {
	Label string    `json:"label,omitempty"`
	Value Threshold `json:"value"`
}

Thresholds is a struct representing a KPI threshold @Deprecated

type WildcardQuery added in v4.4.8

type WildcardQuery struct {
	Type  string      `json:"type"`
	Field string      `json:"field"`
	Value interface{} `json:"value"`
}

func (*WildcardQuery) Contextualize added in v4.4.8

func (q *WildcardQuery) Contextualize(key string, value string)

Contextualize contextualize the current query filter with key-value system

func (*WildcardQuery) Source added in v4.4.8

func (q *WildcardQuery) Source() elastic.Query

Jump to

Keyboard shortcuts

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