comparison

package
v1.0.19 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comparator

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

Comparator object

func NewComparator

func NewComparator(client elasticsearch.Client, index string) Comparator

NewComparator returns a new comparator for the given index and elasticsearch client

func (*Comparator) Compare

func (c *Comparator) Compare(field, query string, stat Stat, value float64, tolerancy int) (string, error)

Compare returns error if value does not meet the tolerance as compared with the field extracted from the given query

Where field is the field we want to compare, query is the query string to use for the search, stat is the type of aggregation to compare with value and toleration is the percentaje difference tolerated, it can negative it returns an error when the field doesn't meet the tolerancy, and an informative message when it does

type QueryStringResponse

type QueryStringResponse struct {
	Aggregations struct {
		// contains filtered or unexported fields
	} `json:"aggregations"`
}

Type to store query response

type Stat

type Stat string
const (
	Min Stat = "min"
	Max Stat = "max"
	Avg Stat = "avg"
	Sum Stat = "sum"
)

Constant for all the stats

Jump to

Keyboard shortcuts

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