query

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package query provides a fluent, type-safe way to build Elasticsearch queries

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder represents a query builder that constructs Elasticsearch queries

func Exists

func Exists(field string) *Builder

Exists creates an exists query builder

func Filter

func Filter(queries ...*Builder) *Builder

Filter creates a filter clause

func Fuzzy

func Fuzzy(field string, value string) *Builder

Fuzzy creates a fuzzy query builder

func IDs

func IDs(ids ...string) *Builder

IDs creates an ids query builder

func Match

func Match(field string, text string) *Builder

Match creates a match query builder

func MatchAll

func MatchAll() *Builder

MatchAll creates a match_all query builder

func MatchNone

func MatchNone() *Builder

MatchNone creates a match_none query builder

func MatchPhrase

func MatchPhrase(field string, text string) *Builder

MatchPhrase creates a match_phrase query builder

func MultiMatch

func MultiMatch(text string, fields ...string) *Builder

MultiMatch creates a multi_match query builder

func Must

func Must(queries ...*Builder) *Builder

Must creates a must clause

func MustNot

func MustNot(queries ...*Builder) *Builder

MustNot creates a must_not clause

func New

func New() *Builder

New creates a new query builder with a bool query

func Prefix

func Prefix(field string, prefix string) *Builder

Prefix creates a prefix query builder

func Regexp

func Regexp(field string, pattern string) *Builder

Regexp creates a regexp query builder

func Should

func Should(queries ...*Builder) *Builder

Should creates a should clause

func Term

func Term(field string, value any) *Builder

Term creates a term query builder

func Terms

func Terms(field string, values ...any) *Builder

Terms creates a terms query builder

func Wildcard

func Wildcard(field string, pattern string) *Builder

Wildcard creates a wildcard query builder

func (*Builder) Build

func (b *Builder) Build() map[string]any

Build returns the internal query map

func (*Builder) Filter

func (b *Builder) Filter(queries ...*Builder) *Builder

Filter adds one or more queries to the filter clause

func (*Builder) MarshalJSON

func (b *Builder) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (*Builder) MinimumShouldMatch

func (b *Builder) MinimumShouldMatch(count int) *Builder

MinimumShouldMatch sets the minimum number of should clauses that must match

func (*Builder) Must

func (b *Builder) Must(queries ...*Builder) *Builder

Must adds one or more queries to the must clause

func (*Builder) MustNot

func (b *Builder) MustNot(queries ...*Builder) *Builder

MustNot adds one or more queries to the must_not clause

func (*Builder) Should

func (b *Builder) Should(queries ...*Builder) *Builder

Should adds one or more queries to the should clause

func (*Builder) String

func (b *Builder) String() string

String returns a JSON representation of the query

type RangeBuilder

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

RangeBuilder provides a fluent interface for building range queries

func Range

func Range(field string) *RangeBuilder

Range creates a new range query builder for the specified field

func (*RangeBuilder) Build

func (r *RangeBuilder) Build() *Builder

Build converts the range builder to a query builder

func (*RangeBuilder) Format

func (r *RangeBuilder) Format(format string) *RangeBuilder

Format sets the date format for date range queries

func (*RangeBuilder) Gt

func (r *RangeBuilder) Gt(value any) *RangeBuilder

Gt sets the greater than value

func (*RangeBuilder) Gte

func (r *RangeBuilder) Gte(value any) *RangeBuilder

Gte sets the greater than or equal to value

func (*RangeBuilder) Lt

func (r *RangeBuilder) Lt(value any) *RangeBuilder

Lt sets the less than value

func (*RangeBuilder) Lte

func (r *RangeBuilder) Lte(value any) *RangeBuilder

Lte sets the less than or equal to value

func (*RangeBuilder) TimeZone

func (r *RangeBuilder) TimeZone(tz string) *RangeBuilder

TimeZone sets the timezone for date range queries

Jump to

Keyboard shortcuts

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