Documentation ¶
Index ¶
- func PtrBool(b bool) *bool
- func PtrFloat(f float64) *float64
- type Accessor
- type And
- type BoostRuleOneOf
- type BoostWhenFieldRuleOneOf
- type ConstBoost
- type DescriptionOfBestResult
- type Eq
- type EqTo
- type Field
- type FieldRuleOneOf
- type FiledBoostRule
- type FiledRule
- type GrThan
- type Gt
- type HumanFriendlyRules
- type InterpretValueAST
- type IntrprateOperatorAST
- func (e *IntrprateOperatorAST) Eval(ast Operator, data MapAny) bool
- func (e *IntrprateOperatorAST) Value(v Value, data MapAny) (value interface{}, found bool)
- func (e *IntrprateOperatorAST) VisitAnd(v *And) any
- func (e *IntrprateOperatorAST) VisitEq(v *Eq) any
- func (e *IntrprateOperatorAST) VisitGt(v *Gt) any
- func (e *IntrprateOperatorAST) VisitNot(v *Not) any
- func (e *IntrprateOperatorAST) VisitOr(v *Or) any
- type Lit
- type MapAny
- type Not
- type Or
- type OrFields
- type RuleOneOf
- type ScoreCalculationFromDescriptionOfBestResult
- type ScoreCalculationFromHumanFriendlyRules
- type TranslateSyntaxASTtoOperatorAST
- type ValueBoost
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BoostRuleOneOf ¶
type BoostRuleOneOf struct { ConstBoost *ConstBoost `json:"boost,omitempty"` ValueBoost *ValueBoost `json:"valueBoost,omitempty"` }
type BoostWhenFieldRuleOneOf ¶
type BoostWhenFieldRuleOneOf struct { Boost *float64 `json:"boost,omitempty"` // multiply score by value in field MultiplyUsingFieldValue *bool `json:"multiply,omitempty"` // There can be more operations supported When FieldRuleOneOf `json:"when"` }
type ConstBoost ¶
type DescriptionOfBestResult ¶
type DescriptionOfBestResult struct { AtLeastOneOf []BoostWhenFieldRuleOneOf `json:"atLeastOneOf"` MustMatchOneOf []FieldRuleOneOf `json:"mustMatchOneOf"` }
type FieldRuleOneOf ¶
type FieldRuleOneOf struct { Field Field `json:"field,omitempty"` Eq interface{} `json:"eq,omitempty"` Gt interface{} `json:"gt,omitempty"` Or *FieldRuleOneOf `json:"or,omitempty"` And *FieldRuleOneOf `json:"and,omitempty"` Not *FieldRuleOneOf `json:"not,omitempty"` }
func (FieldRuleOneOf) ToOperation ¶
func (a FieldRuleOneOf) ToOperation() Operator
type FiledBoostRule ¶
type FiledBoostRule map[Field]BoostRuleOneOf
type HumanFriendlyRules ¶
type HumanFriendlyRules struct { // OneOf implies OR for list of rules - AtLeastOneOf // Lack of it implies AND for list of rules - MustMatch AtLeastOneOf []FiledBoostRule `json:"atLeastOneOf"` MustMatch []FiledRule `json:"mustMatch"` }
func (HumanFriendlyRules) MustMatchToOperation ¶
func (ast HumanFriendlyRules) MustMatchToOperation() Operator
type InterpretValueAST ¶
type InterpretValueAST struct {
V MapAny
}
func (*InterpretValueAST) VisitAccessor ¶
func (e *InterpretValueAST) VisitAccessor(v *Accessor) any
func (*InterpretValueAST) VisitLit ¶
func (e *InterpretValueAST) VisitLit(v *Lit) any
type IntrprateOperatorAST ¶
type IntrprateOperatorAST struct {
// contains filtered or unexported fields
}
func NewInterpreter ¶
func NewInterpreter() *IntrprateOperatorAST
func (*IntrprateOperatorAST) Eval ¶
func (e *IntrprateOperatorAST) Eval(ast Operator, data MapAny) bool
func (*IntrprateOperatorAST) Value ¶
func (e *IntrprateOperatorAST) Value(v Value, data MapAny) (value interface{}, found bool)
func (*IntrprateOperatorAST) VisitAnd ¶
func (e *IntrprateOperatorAST) VisitAnd(v *And) any
func (*IntrprateOperatorAST) VisitEq ¶
func (e *IntrprateOperatorAST) VisitEq(v *Eq) any
func (*IntrprateOperatorAST) VisitGt ¶
func (e *IntrprateOperatorAST) VisitGt(v *Gt) any
func (*IntrprateOperatorAST) VisitNot ¶
func (e *IntrprateOperatorAST) VisitNot(v *Not) any
func (*IntrprateOperatorAST) VisitOr ¶
func (e *IntrprateOperatorAST) VisitOr(v *Or) any
type RuleOneOf ¶
type RuleOneOf struct { Eq interface{} `json:"eq,omitempty"` Gt interface{} `json:"gt,omitempty"` }
type ScoreCalculationFromDescriptionOfBestResult ¶
type ScoreCalculationFromDescriptionOfBestResult struct {
// contains filtered or unexported fields
}
func NewScoreCalculatorFromDescriptionOfBestResult ¶
func NewScoreCalculatorFromDescriptionOfBestResult() *ScoreCalculationFromDescriptionOfBestResult
func (*ScoreCalculationFromDescriptionOfBestResult) Calculate ¶
func (s *ScoreCalculationFromDescriptionOfBestResult) Calculate(ast DescriptionOfBestResult, data MapAny) (score float64)
Calculate is based on rule that - must match - then allow should match calculation, otherwise score is 0 - should - takes and adds score from all should rules - result is final score for given data record
type ScoreCalculationFromHumanFriendlyRules ¶
type ScoreCalculationFromHumanFriendlyRules struct {
// contains filtered or unexported fields
}
func NewScoreCalculatorFromHumanFriendlyRules ¶
func NewScoreCalculatorFromHumanFriendlyRules() *ScoreCalculationFromHumanFriendlyRules
func (*ScoreCalculationFromHumanFriendlyRules) Calculate ¶
func (s *ScoreCalculationFromHumanFriendlyRules) Calculate(ast HumanFriendlyRules, data MapAny) (score float64)
Calculate is based on rule that - must match - then allow should match calculation, otherwise score is 0 - should - takes and adds score from all should rules - result is final score for given data record
type TranslateSyntaxASTtoOperatorAST ¶
type TranslateSyntaxASTtoOperatorAST struct {
// contains filtered or unexported fields
}
func (*TranslateSyntaxASTtoOperatorAST) VisitEqTo ¶
func (a *TranslateSyntaxASTtoOperatorAST) VisitEqTo(v *EqTo) any
func (*TranslateSyntaxASTtoOperatorAST) VisitGrThan ¶
func (a *TranslateSyntaxASTtoOperatorAST) VisitGrThan(v *GrThan) any
func (*TranslateSyntaxASTtoOperatorAST) VisitOrFields ¶
func (a *TranslateSyntaxASTtoOperatorAST) VisitOrFields(v *OrFields) any
type ValueBoost ¶
type ValueBoost struct {
RuleOneOf
}
Click to show internal directories.
Click to hide internal directories.