query

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BooleanQuery

type BooleanQuery struct {
	Must    []Filter      // AND conditions
	Should  []Filter      // OR conditions
	MustNot []Filter      // NOT conditions
	Nested  *BooleanQuery // Nested boolean query (for parentheses)
}

BooleanQuery represents a boolean combination of filters

type Builder

type Builder struct{}

Builder handles converting queries into SQL

func NewBuilder

func NewBuilder() *Builder

NewBuilder creates a new query builder

func (*Builder) BuildConditions

func (b *Builder) BuildConditions(bq *BooleanQuery) ([]string, []interface{}, error)

func (*Builder) BuildSQL

func (b *Builder) BuildSQL(q *Query, baseQuery string) (string, []interface{}, error)

BuildSQL converts a Query into a SQL query with parameters

type FieldType added in v0.4.0

type FieldType string

FieldType represents the type of field being queried

const (
	FieldMetadata  FieldType = "metadata"
	FieldAssetType FieldType = "type"
	FieldProvider  FieldType = "provider"
	FieldKind      FieldType = "kind"
	FieldName      FieldType = "name"
)

type Filter

type Filter struct {
	Field     []string    // Field to filter on (e.g., "metadata.owner")
	FieldType FieldType   // Type of field (metadata, type, provider, kind)
	Operator  Operator    // Operator (e.g., =, :, contains)
	Value     interface{} // Value to compare against
	Range     *RangeValue // Range values for range queries
	OrigQuery string
}

Filter represents a single filter condition

type Operator

type Operator string

Operator represents the type of filter operation

const (
	OpEquals       Operator = "="
	OpContains     Operator = "contains"
	OpNotEquals    Operator = "!="
	OpGreater      Operator = ">"
	OpLess         Operator = "<"
	OpGreaterEqual Operator = ">="
	OpLessEqual    Operator = "<="
	OpIn           Operator = "in"
	OpNotIn        Operator = "not in"
	OpRange        Operator = "range"
	OpWildcard     Operator = "wildcard"
	OpFreeText     Operator = "freetext"
)

type Parser

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

Parser handles parsing of search queries into structured formats

func NewParser

func NewParser() *Parser

NewParser creates a new query parser

func (*Parser) Parse

func (p *Parser) Parse(queryStr string) (*Query, error)

Parse parses a search string into a structured query

type Query

type Query struct {
	FreeText string        // General text search
	Filters  []Filter      // Specific field filters
	Bool     *BooleanQuery // Boolean combinations of filters
}

Query represents a parsed search query with specific conditions

type RangeValue

type RangeValue struct {
	From      interface{}
	To        interface{}
	Inclusive bool
}

RangeValue represents a range query with optional bounds

type Tokeniser

type Tokeniser struct{}

Tokeniser handles breaking down search queries into tokens

func NewTokeniser

func NewTokeniser() *Tokeniser

NewTokeniser creates a new tokenizer

func (*Tokeniser) Tokenise

func (t *Tokeniser) Tokenise(query string) ([]string, error)

Tokenise splits a query string into tokens while preserving quoted strings and operators

Jump to

Keyboard shortcuts

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