expr

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsExpr

func IsExpr(in any) bool

IsExpr checks if the input is an expression

func Validate

func Validate(in any) (err error)

Validate validates the expression is correctly structured.

Types

type Column

type Column string

Column represents a column in sql. It will not be escaped by quotes in the sql rendering

func (Column) GoString

func (c Column) GoString() string

GoString is a debug print for the column type

type Expression

type Expression struct {
	Left  any      `json:"left"`
	Op    Operator `json:"-"`
	Right any      `json:"right,omitempty"`
	// contains filtered or unexported fields
}

Expression is an interface over all the different types of expressions that we can parse out of lucene

func AND

func AND(a, b any) *Expression

AND creates an AND expression

func BOOST

func BOOST(e any, power ...float64) *Expression

BOOST wraps an expression in a boost

func Eq

func Eq(a any, b any) *Expression

Eq creates a new EQUALS expression

func Expr

func Expr(left any, op Operator, right ...any) *Expression

Expr creates a general new expression. The other public functions are just helpers that call this function underneath.

func FUZZY

func FUZZY(e any, distance ...int) *Expression

FUZZY wraps an expression in a fuzzy

func GREATER

func GREATER(a any, b any) *Expression

func GREATEREQ

func GREATEREQ(a any, b any) *Expression

func IN

func IN(a any, b any) *Expression

func LESS

func LESS(a any, b any) *Expression

func LESSEQ

func LESSEQ(a any, b any) *Expression

func LIKE

func LIKE(a any, b any) *Expression

LIKE creates a new fuzzy matching LIKE expression

func LIST

func LIST(a ...any) *Expression

func Lit

func Lit(in any) *Expression

Lit represents a literal expression

func MUST

func MUST(e any) *Expression

MUST wraps an expression in a Must

func MUSTNOT

func MUSTNOT(e any) *Expression

MUSTNOT wraps an expression in a MustNot

func NOT

func NOT(e any) *Expression

NOT wraps an expression in a Not

func OR

func OR(a, b any) *Expression

OR creates a new OR expression

func REGEXP

func REGEXP(in any) *Expression

REGEXP represents a literal regular expression

func Rang

func Rang(term any, min, max any, inclusive bool) *Expression

Rang creates a new range expression

func WILD

func WILD(in any) *Expression

WILD represents a literal wildcard expression

func (Expression) GoString

func (e Expression) GoString() string

GoString prints a verbose string representation. Useful for debugging exactly what types were parsed. You can print this format using %#v

func (Expression) MarshalJSON

func (e Expression) MarshalJSON() (out []byte, err error)

MarshalJSON is a custom JSON serialization for the Expression

func (Expression) String

func (e Expression) String() string

func (*Expression) UnmarshalJSON

func (e *Expression) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON is a custom JSON deserialization for the Expression

type Operator

type Operator int

Operator is an enum over the different valid lucene operations

const (
	Undefined Operator = iota
	And
	Or
	Equals
	Like
	Not
	Range
	Must
	MustNot
	Boost
	Fuzzy
	Literal
	Wild
	Regexp
	Greater
	Less
	GreaterEq
	LessEq
	In
	List
)

operations that can be used To add a new operator, do the following: 1. Add it to the iota here 2. Add it to the string maps below 3. Add a render function for it at least in base, perhaps in all the drivers as well 4. Update the json parsing and tests to support the new operator 5. Add tests in parse_test and expression_test

func (Operator) String

func (o Operator) String() string

String renders the operator as a string

type RangeBoundary

type RangeBoundary struct {
	Min       any  `json:"min"`
	Max       any  `json:"max"`
	Inclusive bool `json:"inclusive"`
}

RangeBoundary represents the boundary conditions for a range operator

Jump to

Keyboard shortcuts

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