lucene

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 4 Imported by: 0

README

lucene

CI Status codecov Go Report Card CodeQL Go Reference License Go Version Release

Type-safe search queries for Elasticsearch and OpenSearch. Compile-time field validation ensures your queries reference fields that actually exist.

Your Struct, Your Schema

type Product struct {
    Title    string  `json:"title"`
    Category string  `json:"category"`
    Price    float64 `json:"price"`
}

b, _ := lucene.New[Product]()

// This compiles - "title" exists
query := b.Match("title", "laptop")

// This fails at build time - "titl" doesn't exist
query := b.Match("titl", "laptop")  // unknown field: titl

Your Go struct becomes the source of truth. No more runtime surprises from typos in field names.

Install

go get github.com/zoobzio/lucene

Quick Start

package main

import (
    "fmt"

    "github.com/zoobzio/lucene"
    "github.com/zoobzio/lucene/elasticsearch"
)

type Article struct {
    Title     string   `json:"title"`
    Body      string   `json:"body"`
    Author    string   `json:"author"`
    Published string   `json:"published"`
    Views     int      `json:"views"`
}

func main() {
    // Create a type-safe builder
    b, err := lucene.New[Article]()
    if err != nil {
        panic(err)
    }

    // Build a search request
    search := lucene.NewSearch().
        Query(
            b.Bool().
                Must(b.Match("title", "golang")).
                Filter(b.Range("views").Gte(1000)).
                Should(b.Term("author", "gopher")),
        ).
        Aggs(b.TermsAgg("by_author", "author").Size(10)).
        Size(20)

    // Render to Elasticsearch JSON
    renderer := elasticsearch.NewRenderer(elasticsearch.V8)
    json, err := renderer.Render(search)
    if err != nil {
        panic(err)
    }

    fmt.Println(string(json))
}

Capabilities

Feature Description
Full-text queries Match, match_phrase, multi_match, query_string
Term-level queries Term, terms, range, prefix, wildcard, regexp, fuzzy, exists
Compound queries Bool, boosting, constant_score, dis_max
Joining queries Nested, has_child, has_parent
Geo queries Geo_distance, geo_bounding_box
Vector search k-NN with filter support
Aggregations Terms, histogram, date_histogram, range, metrics, pipeline
Search features Sort, pagination, source filtering, highlighting

Why lucene?

  • Catch errors early - Field validation happens when you build the query, not when Elasticsearch rejects it
  • Chain naturally - Fluent builder methods return typed results; check .Err() once at the end
  • Target both engines - Same query AST renders to Elasticsearch or OpenSearch JSON
  • Cover the DSL - Bool queries, aggregations, geo, vectors, highlights - it's all there

The Zoobzio Ecosystem

lucene works alongside other zoobzio packages:

Package Purpose
sentinel Struct metadata extraction (powers lucene's schema)

Documentation

Learn

Guides

Reference

Contributing

See CONTRIBUTING.md for guidelines.

License

MIT License - see LICENSE

Documentation

Overview

Package lucene provides a type-safe query builder for OpenSearch and Elasticsearch.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownField = errors.New("unknown field")

ErrUnknownField is returned when a field is not found in the schema.

Functions

This section is empty.

Types

type AggType

type AggType uint8

AggType represents an aggregation type.

const (
	// AggTerms groups documents by field value.
	AggTerms AggType = iota
	// AggHistogram creates numeric buckets.
	AggHistogram
	// AggDateHistogram creates time-based buckets.
	AggDateHistogram
	// AggRange creates custom range buckets.
	AggRange
	// AggDateRange creates date range buckets.
	AggDateRange
	// AggFilter creates a single filter bucket.
	AggFilter
	// AggFilters creates named filter buckets.
	AggFilters
	// AggNested aggregates nested documents.
	AggNested
	// AggMissing counts documents missing a field.
	AggMissing

	// AggAvg computes the average value.
	AggAvg
	// AggSum computes the sum of values.
	AggSum
	// AggMin computes the minimum value.
	AggMin
	// AggMax computes the maximum value.
	AggMax
	// AggCount counts values.
	AggCount
	// AggCardinality counts distinct values.
	AggCardinality
	// AggStats computes basic statistics.
	AggStats
	// AggExtendedStats computes extended statistics.
	AggExtendedStats
	// AggPercentiles computes percentile values.
	AggPercentiles
	// AggTopHits returns top matching documents.
	AggTopHits

	// AggAvgBucket computes the average of bucket values.
	AggAvgBucket
	// AggSumBucket computes the sum of bucket values.
	AggSumBucket
	// AggMaxBucket finds the maximum bucket value.
	AggMaxBucket
	// AggMinBucket finds the minimum bucket value.
	AggMinBucket
	// AggDerivative computes the derivative of a metric.
	AggDerivative
	// AggCumulativeSum computes the cumulative sum.
	AggCumulativeSum
	// AggMovingAvg computes a moving average.
	AggMovingAvg
)

type Aggregation

type Aggregation interface {
	// Name returns the aggregation name.
	Name() string

	// Type returns the aggregation type.
	Type() AggType

	// Field returns the field name.
	Field() string

	// SubAggs returns sub-aggregations.
	SubAggs() []Aggregation

	// Err returns any error.
	Err() error
	// contains filtered or unexported methods
}

Aggregation is the interface for aggregation types.

type AvgAgg

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

AvgAgg computes the average value.

func (*AvgAgg) Err

func (a *AvgAgg) Err() error

func (*AvgAgg) Field

func (a *AvgAgg) Field() string

func (*AvgAgg) Missing

func (a *AvgAgg) Missing(m any) *AvgAgg

Missing sets the value to use for missing fields.

func (*AvgAgg) MissingValue

func (a *AvgAgg) MissingValue() any

MissingValue returns the missing value if set.

func (*AvgAgg) Name

func (a *AvgAgg) Name() string

func (*AvgAgg) SubAggs

func (a *AvgAgg) SubAggs() []Aggregation

func (*AvgAgg) Type

func (a *AvgAgg) Type() AggType

type AvgBucketAgg

type AvgBucketAgg struct {
	PipelineAgg
}

AvgBucketAgg computes the average of bucket values.

func (*AvgBucketAgg) Err

func (a *AvgBucketAgg) Err() error

func (*AvgBucketAgg) Field

func (a *AvgBucketAgg) Field() string

func (*AvgBucketAgg) Name

func (a *AvgBucketAgg) Name() string

func (*AvgBucketAgg) SubAggs

func (a *AvgBucketAgg) SubAggs() []Aggregation

func (*AvgBucketAgg) Type

func (a *AvgBucketAgg) Type() AggType

type BoolQuery

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

BoolQuery combines queries with boolean logic.

func (*BoolQuery) Boost

func (q *BoolQuery) Boost(b float64) *BoolQuery

Boost sets the relevance score multiplier.

func (*BoolQuery) BoostValue

func (q *BoolQuery) BoostValue() *float64

BoostValue returns the boost value if set.

func (*BoolQuery) Err

func (q *BoolQuery) Err() error

Err returns the first error found in this query or any of its children.

func (*BoolQuery) Field

func (q *BoolQuery) Field() string

func (*BoolQuery) Filter

func (q *BoolQuery) Filter(queries ...Query) *BoolQuery

Filter adds queries that must match but don't affect scoring.

func (*BoolQuery) FilterClauses

func (q *BoolQuery) FilterClauses() []Query

FilterClauses returns the filter clauses.

func (*BoolQuery) MinimumShouldMatch

func (q *BoolQuery) MinimumShouldMatch(n int) *BoolQuery

MinimumShouldMatch sets the minimum number of should clauses that must match.

func (*BoolQuery) MinimumShouldMatchValue

func (q *BoolQuery) MinimumShouldMatchValue() *int

MinimumShouldMatchValue returns the minimum_should_match value if set.

func (*BoolQuery) Must

func (q *BoolQuery) Must(queries ...Query) *BoolQuery

Must adds queries that must match.

func (*BoolQuery) MustClauses

func (q *BoolQuery) MustClauses() []Query

MustClauses returns the must clauses.

func (*BoolQuery) MustNot

func (q *BoolQuery) MustNot(queries ...Query) *BoolQuery

MustNot adds queries that must not match.

func (*BoolQuery) MustNotClauses

func (q *BoolQuery) MustNotClauses() []Query

MustNotClauses returns the must_not clauses.

func (*BoolQuery) Op

func (q *BoolQuery) Op() Op

func (*BoolQuery) Should

func (q *BoolQuery) Should(queries ...Query) *BoolQuery

Should adds queries that should match.

func (*BoolQuery) ShouldClauses

func (q *BoolQuery) ShouldClauses() []Query

ShouldClauses returns the should clauses.

func (*BoolQuery) Value

func (q *BoolQuery) Value() any

type BoostingQuery

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

BoostingQuery demotes documents matching a negative query.

func (*BoostingQuery) Err

func (q *BoostingQuery) Err() error

Err returns any error in this query or its children.

func (*BoostingQuery) Field

func (q *BoostingQuery) Field() string

func (*BoostingQuery) Negative

func (q *BoostingQuery) Negative(n Query) *BoostingQuery

Negative sets the query to demote matching documents.

func (*BoostingQuery) NegativeBoost

func (q *BoostingQuery) NegativeBoost(b float64) *BoostingQuery

NegativeBoost sets the score multiplier for negative matches (0-1).

func (*BoostingQuery) NegativeBoostValue

func (q *BoostingQuery) NegativeBoostValue() *float64

NegativeBoostValue returns the negative_boost value if set.

func (*BoostingQuery) NegativeQuery

func (q *BoostingQuery) NegativeQuery() Query

NegativeQuery returns the negative query.

func (*BoostingQuery) Op

func (q *BoostingQuery) Op() Op

func (*BoostingQuery) Positive

func (q *BoostingQuery) Positive(p Query) *BoostingQuery

Positive sets the query that must match.

func (*BoostingQuery) PositiveQuery

func (q *BoostingQuery) PositiveQuery() Query

PositiveQuery returns the positive query.

func (*BoostingQuery) Value

func (q *BoostingQuery) Value() any

type Builder

type Builder[T any] struct {
	// contains filtered or unexported fields
}

Builder provides schema-validated query building for type T.

func New

func New[T any]() (*Builder[T], error)

New creates a new Builder for type T. Returns an error if T is not a struct or cannot be inspected.

func (*Builder[T]) And

func (b *Builder[T]) And(queries ...Query) *BoolQuery

And is a convenience method that creates a bool query with must clauses.

func (*Builder[T]) Avg

func (b *Builder[T]) Avg(name, field string) *AvgAgg

Avg creates an avg aggregation.

func (*Builder[T]) AvgBucket

func (b *Builder[T]) AvgBucket(name, bucketsPath string) *AvgBucketAgg

AvgBucket creates an avg_bucket pipeline aggregation.

func (*Builder[T]) Bool

func (b *Builder[T]) Bool() *BoolQuery

Bool creates a bool query for combining queries with boolean logic.

func (*Builder[T]) Boosting

func (b *Builder[T]) Boosting() *BoostingQuery

Boosting creates a boosting query.

func (*Builder[T]) Cardinality

func (b *Builder[T]) Cardinality(name, field string) *CardinalityAgg

Cardinality creates a cardinality aggregation.

func (*Builder[T]) ConstantScore

func (b *Builder[T]) ConstantScore(filter Query) *ConstantScoreQuery

ConstantScore creates a constant_score query.

func (*Builder[T]) Count

func (b *Builder[T]) Count(name, field string) *CountAgg

Count creates a value_count aggregation.

func (*Builder[T]) CumulativeSum

func (b *Builder[T]) CumulativeSum(name, bucketsPath string) *CumulativeSumAgg

CumulativeSum creates a cumulative_sum pipeline aggregation.

func (*Builder[T]) DateHistogram

func (b *Builder[T]) DateHistogram(name, field string) *DateHistogramAgg

DateHistogram creates a date histogram aggregation.

func (*Builder[T]) DateRangeAgg

func (b *Builder[T]) DateRangeAgg(name, field string) *DateRangeAgg

DateRangeAgg creates a date_range aggregation.

func (*Builder[T]) Derivative

func (b *Builder[T]) Derivative(name, bucketsPath string) *DerivativeAgg

Derivative creates a derivative pipeline aggregation.

func (*Builder[T]) DisMax

func (b *Builder[T]) DisMax(queries ...Query) *DisMaxQuery

DisMax creates a dis_max query.

func (*Builder[T]) Exists

func (b *Builder[T]) Exists(field string) *ExistsQuery

Exists creates an exists query.

func (*Builder[T]) ExtendedStats

func (b *Builder[T]) ExtendedStats(name, field string) *ExtendedStatsAgg

ExtendedStats creates an extended_stats aggregation.

func (*Builder[T]) FilterAgg

func (b *Builder[T]) FilterAgg(name string, filter Query) *FilterAgg

FilterAgg creates a filter aggregation.

func (*Builder[T]) FiltersAgg

func (b *Builder[T]) FiltersAgg(name string) *FiltersAgg

FiltersAgg creates a filters aggregation with named buckets.

func (*Builder[T]) Fuzzy

func (b *Builder[T]) Fuzzy(field string, value string) *FuzzyQuery

Fuzzy creates a fuzzy query.

func (*Builder[T]) GeoBoundingBox

func (b *Builder[T]) GeoBoundingBox(field string) *GeoBoundingBoxQuery

GeoBoundingBox creates a geo_bounding_box query.

func (*Builder[T]) GeoDistance

func (b *Builder[T]) GeoDistance(field string, lat, lon float64) *GeoDistanceQuery

GeoDistance creates a geo_distance query.

func (*Builder[T]) HasChild

func (b *Builder[T]) HasChild(childType string, inner Query) *HasChildQuery

HasChild creates a has_child query.

func (*Builder[T]) HasParent

func (b *Builder[T]) HasParent(parentType string, inner Query) *HasParentQuery

HasParent creates a has_parent query.

func (*Builder[T]) Histogram

func (b *Builder[T]) Histogram(name, field string) *HistogramAgg

Histogram creates a histogram aggregation.

func (*Builder[T]) IDs

func (b *Builder[T]) IDs(ids ...string) *IDsQuery

IDs creates an IDs query.

func (*Builder[T]) Knn

func (b *Builder[T]) Knn(field string, vector []float32) *KnnQuery

Knn creates a kNN query.

func (*Builder[T]) Match

func (b *Builder[T]) Match(field string, text string) *MatchQuery

Match creates a match query for analyzed text search.

func (*Builder[T]) MatchAll

func (b *Builder[T]) MatchAll() *MatchAllQuery

MatchAll creates a query that matches all documents.

func (*Builder[T]) MatchNone

func (b *Builder[T]) MatchNone() *MatchNoneQuery

MatchNone creates a query that matches no documents.

func (*Builder[T]) MatchPhrase

func (b *Builder[T]) MatchPhrase(field string, phrase string) *MatchPhraseQuery

MatchPhrase creates a match phrase query for exact phrase matching.

func (*Builder[T]) MatchPhrasePrefix

func (b *Builder[T]) MatchPhrasePrefix(field string, phrase string) *MatchPhrasePrefixQuery

MatchPhrasePrefix creates a match phrase prefix query for autocomplete.

func (*Builder[T]) Max

func (b *Builder[T]) Max(name, field string) *MaxAgg

Max creates a max aggregation.

func (*Builder[T]) MaxBucket

func (b *Builder[T]) MaxBucket(name, bucketsPath string) *MaxBucketAgg

MaxBucket creates a max_bucket pipeline aggregation.

func (*Builder[T]) Min

func (b *Builder[T]) Min(name, field string) *MinAgg

Min creates a min aggregation.

func (*Builder[T]) MinBucket

func (b *Builder[T]) MinBucket(name, bucketsPath string) *MinBucketAgg

MinBucket creates a min_bucket pipeline aggregation.

func (*Builder[T]) MissingAgg

func (b *Builder[T]) MissingAgg(name, field string) *MissingAgg

MissingAgg creates a missing aggregation.

func (*Builder[T]) MovingAvg

func (b *Builder[T]) MovingAvg(name, bucketsPath string) *MovingAvgAgg

MovingAvg creates a moving_avg pipeline aggregation.

func (*Builder[T]) MultiMatch

func (b *Builder[T]) MultiMatch(text string, fields ...string) *MultiMatchQuery

MultiMatch creates a multi-match query for searching across multiple fields. Fields are validated; if any field is invalid, the query carries an error.

func (*Builder[T]) Nested

func (b *Builder[T]) Nested(path string, inner Query) *NestedQuery

Nested creates a nested query.

func (*Builder[T]) NestedAgg

func (b *Builder[T]) NestedAgg(name, path string) *NestedAgg

NestedAgg creates a nested aggregation.

func (*Builder[T]) Not

func (b *Builder[T]) Not(q Query) *BoolQuery

Not is a convenience method that creates a bool query with a must_not clause.

func (*Builder[T]) Or

func (b *Builder[T]) Or(queries ...Query) *BoolQuery

Or is a convenience method that creates a bool query with should clauses and minimum_should_match set to 1.

func (*Builder[T]) Percentiles

func (b *Builder[T]) Percentiles(name, field string) *PercentilesAgg

Percentiles creates a percentiles aggregation.

func (*Builder[T]) Prefix

func (b *Builder[T]) Prefix(field string, prefix string) *PrefixQuery

Prefix creates a prefix query.

func (*Builder[T]) QueryString

func (b *Builder[T]) QueryString(queryStr string) *QueryStringQuery

QueryString creates a query_string query.

func (*Builder[T]) Range

func (b *Builder[T]) Range(field string) *RangeQuery

Range creates a range query builder.

func (*Builder[T]) RangeAgg

func (b *Builder[T]) RangeAgg(name, field string) *RangeAgg

RangeAgg creates a range aggregation.

func (*Builder[T]) Regexp

func (b *Builder[T]) Regexp(field string, pattern string) *RegexpQuery

Regexp creates a regexp query.

func (*Builder[T]) SimpleQueryString

func (b *Builder[T]) SimpleQueryString(queryStr string) *SimpleQueryStringQuery

SimpleQueryString creates a simple_query_string query.

func (*Builder[T]) Spec

func (b *Builder[T]) Spec() *Spec

Spec returns the extracted schema specification.

func (*Builder[T]) Stats

func (b *Builder[T]) Stats(name, field string) *StatsAgg

Stats creates a stats aggregation.

func (*Builder[T]) Sum

func (b *Builder[T]) Sum(name, field string) *SumAgg

Sum creates a sum aggregation.

func (*Builder[T]) SumBucket

func (b *Builder[T]) SumBucket(name, bucketsPath string) *SumBucketAgg

SumBucket creates a sum_bucket pipeline aggregation.

func (*Builder[T]) Term

func (b *Builder[T]) Term(field string, value any) *TermQuery

Term creates a term query for exact value matching.

func (*Builder[T]) Terms

func (b *Builder[T]) Terms(field string, values ...any) *TermsQuery

Terms creates a terms query for matching any of multiple values.

func (*Builder[T]) TermsAgg

func (b *Builder[T]) TermsAgg(name, field string) *TermsAgg

TermsAgg creates a terms aggregation.

func (*Builder[T]) TopHits

func (b *Builder[T]) TopHits(name string) *TopHitsAgg

TopHits creates a top_hits aggregation.

func (*Builder[T]) Wildcard

func (b *Builder[T]) Wildcard(field string, pattern string) *WildcardQuery

Wildcard creates a wildcard query.

type CardinalityAgg

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

CardinalityAgg counts distinct values.

func (*CardinalityAgg) Err

func (a *CardinalityAgg) Err() error

func (*CardinalityAgg) Field

func (a *CardinalityAgg) Field() string

func (*CardinalityAgg) Name

func (a *CardinalityAgg) Name() string

func (*CardinalityAgg) PrecisionThreshold

func (a *CardinalityAgg) PrecisionThreshold(p int) *CardinalityAgg

PrecisionThreshold sets the precision threshold.

func (*CardinalityAgg) PrecisionThresholdValue

func (a *CardinalityAgg) PrecisionThresholdValue() *int

PrecisionThresholdValue returns the precision_threshold if set.

func (*CardinalityAgg) SubAggs

func (a *CardinalityAgg) SubAggs() []Aggregation

func (*CardinalityAgg) Type

func (a *CardinalityAgg) Type() AggType

type ConstantScoreQuery

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

ConstantScoreQuery wraps a filter with a constant score.

func (*ConstantScoreQuery) Boost

Boost sets the constant score value.

func (*ConstantScoreQuery) BoostValue

func (q *ConstantScoreQuery) BoostValue() *float64

BoostValue returns the boost value if set.

func (*ConstantScoreQuery) Err

func (q *ConstantScoreQuery) Err() error

Err returns any error in this query or its filter.

func (*ConstantScoreQuery) Field

func (q *ConstantScoreQuery) Field() string

func (*ConstantScoreQuery) FilterQuery

func (q *ConstantScoreQuery) FilterQuery() Query

FilterQuery returns the wrapped filter query.

func (*ConstantScoreQuery) Op

func (q *ConstantScoreQuery) Op() Op

func (*ConstantScoreQuery) Value

func (q *ConstantScoreQuery) Value() any

type CountAgg

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

CountAgg counts values.

func (*CountAgg) Err

func (a *CountAgg) Err() error

func (*CountAgg) Field

func (a *CountAgg) Field() string

func (*CountAgg) Name

func (a *CountAgg) Name() string

func (*CountAgg) SubAggs

func (a *CountAgg) SubAggs() []Aggregation

func (*CountAgg) Type

func (a *CountAgg) Type() AggType

type CumulativeSumAgg

type CumulativeSumAgg struct {
	PipelineAgg
}

CumulativeSumAgg computes the cumulative sum.

func (*CumulativeSumAgg) Err

func (a *CumulativeSumAgg) Err() error

func (*CumulativeSumAgg) Field

func (a *CumulativeSumAgg) Field() string

func (*CumulativeSumAgg) Name

func (a *CumulativeSumAgg) Name() string

func (*CumulativeSumAgg) SubAggs

func (a *CumulativeSumAgg) SubAggs() []Aggregation

func (*CumulativeSumAgg) Type

func (a *CumulativeSumAgg) Type() AggType

type DateHistogramAgg

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

DateHistogramAgg creates time-based buckets.

func (*DateHistogramAgg) CalendarInterval

func (a *DateHistogramAgg) CalendarInterval(i string) *DateHistogramAgg

CalendarInterval sets the calendar-aware interval (e.g., "month", "week").

func (*DateHistogramAgg) CalendarIntervalValue

func (a *DateHistogramAgg) CalendarIntervalValue() *string

CalendarIntervalValue returns the calendar_interval if set.

func (*DateHistogramAgg) Err

func (a *DateHistogramAgg) Err() error

func (*DateHistogramAgg) Field

func (a *DateHistogramAgg) Field() string

func (*DateHistogramAgg) FixedInterval

func (a *DateHistogramAgg) FixedInterval(i string) *DateHistogramAgg

FixedInterval sets the fixed interval (e.g., "1d", "12h").

func (*DateHistogramAgg) FixedIntervalValue

func (a *DateHistogramAgg) FixedIntervalValue() *string

FixedIntervalValue returns the fixed_interval if set.

func (*DateHistogramAgg) Format

Format sets the date format for keys.

func (*DateHistogramAgg) FormatValue

func (a *DateHistogramAgg) FormatValue() *string

FormatValue returns the format if set.

func (*DateHistogramAgg) MinDocCount

func (a *DateHistogramAgg) MinDocCount(m int) *DateHistogramAgg

MinDocCount sets the minimum document count for a bucket.

func (*DateHistogramAgg) MinDocCountValue

func (a *DateHistogramAgg) MinDocCountValue() *int

MinDocCountValue returns the min_doc_count if set.

func (*DateHistogramAgg) Name

func (a *DateHistogramAgg) Name() string

func (*DateHistogramAgg) SubAgg

SubAgg adds a sub-aggregation.

func (*DateHistogramAgg) SubAggs

func (a *DateHistogramAgg) SubAggs() []Aggregation

func (*DateHistogramAgg) TimeZone

func (a *DateHistogramAgg) TimeZone(tz string) *DateHistogramAgg

TimeZone sets the time zone.

func (*DateHistogramAgg) TimeZoneValue

func (a *DateHistogramAgg) TimeZoneValue() *string

TimeZoneValue returns the time_zone if set.

func (*DateHistogramAgg) Type

func (a *DateHistogramAgg) Type() AggType

type DateRangeAgg

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

DateRangeAgg creates date range buckets.

func (*DateRangeAgg) AddKeyedRange

func (a *DateRangeAgg) AddKeyedRange(key string, from, to any) *DateRangeAgg

AddKeyedRange adds a named date range bucket.

func (*DateRangeAgg) AddRange

func (a *DateRangeAgg) AddRange(from, to any) *DateRangeAgg

AddRange adds a date range bucket.

func (*DateRangeAgg) Err

func (a *DateRangeAgg) Err() error

func (*DateRangeAgg) Field

func (a *DateRangeAgg) Field() string

func (*DateRangeAgg) Format

func (a *DateRangeAgg) Format(f string) *DateRangeAgg

Format sets the date format for parsing string values.

func (*DateRangeAgg) FormatValue

func (a *DateRangeAgg) FormatValue() *string

FormatValue returns the format if set.

func (*DateRangeAgg) Keyed

func (a *DateRangeAgg) Keyed(k bool) *DateRangeAgg

Keyed sets whether to return buckets as a map.

func (*DateRangeAgg) KeyedValue

func (a *DateRangeAgg) KeyedValue() *bool

KeyedValue returns the keyed value if set.

func (*DateRangeAgg) Name

func (a *DateRangeAgg) Name() string

func (*DateRangeAgg) Ranges

func (a *DateRangeAgg) Ranges() []DateRangeSpec

Ranges returns the range specifications.

func (*DateRangeAgg) SubAgg

func (a *DateRangeAgg) SubAgg(sub Aggregation) *DateRangeAgg

SubAgg adds a sub-aggregation.

func (*DateRangeAgg) SubAggs

func (a *DateRangeAgg) SubAggs() []Aggregation

func (*DateRangeAgg) Type

func (a *DateRangeAgg) Type() AggType

type DateRangeSpec

type DateRangeSpec struct {
	Key  string
	From any
	To   any
}

DateRangeSpec defines a date range bucket.

type DerivativeAgg

type DerivativeAgg struct {
	PipelineAgg
	// contains filtered or unexported fields
}

DerivativeAgg computes the derivative of a metric.

func (*DerivativeAgg) Err

func (a *DerivativeAgg) Err() error

func (*DerivativeAgg) Field

func (a *DerivativeAgg) Field() string

func (*DerivativeAgg) Name

func (a *DerivativeAgg) Name() string

func (*DerivativeAgg) SubAggs

func (a *DerivativeAgg) SubAggs() []Aggregation

func (*DerivativeAgg) Type

func (a *DerivativeAgg) Type() AggType

func (*DerivativeAgg) Unit

func (a *DerivativeAgg) Unit(u string) *DerivativeAgg

Unit sets the unit for normalization.

func (*DerivativeAgg) UnitValue

func (a *DerivativeAgg) UnitValue() *string

UnitValue returns the unit if set.

type DisMaxQuery

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

DisMaxQuery returns the best match from multiple queries.

func (*DisMaxQuery) Boost

func (q *DisMaxQuery) Boost(b float64) *DisMaxQuery

Boost sets the relevance score multiplier.

func (*DisMaxQuery) BoostValue

func (q *DisMaxQuery) BoostValue() *float64

BoostValue returns the boost value if set.

func (*DisMaxQuery) Err

func (q *DisMaxQuery) Err() error

Err returns any error in this query or its children.

func (*DisMaxQuery) Field

func (q *DisMaxQuery) Field() string

func (*DisMaxQuery) Op

func (q *DisMaxQuery) Op() Op

func (*DisMaxQuery) Queries

func (q *DisMaxQuery) Queries() []Query

Queries returns the dis_max queries.

func (*DisMaxQuery) TieBreaker

func (q *DisMaxQuery) TieBreaker(t float64) *DisMaxQuery

TieBreaker sets the tie breaker multiplier (0-1).

func (*DisMaxQuery) TieBreakerValue

func (q *DisMaxQuery) TieBreakerValue() *float64

TieBreakerValue returns the tie_breaker value if set.

func (*DisMaxQuery) Value

func (q *DisMaxQuery) Value() any

type ExistsQuery

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

ExistsQuery matches documents where the field exists.

func (*ExistsQuery) Err

func (q *ExistsQuery) Err() error

func (*ExistsQuery) Field

func (q *ExistsQuery) Field() string

func (*ExistsQuery) Op

func (q *ExistsQuery) Op() Op

func (*ExistsQuery) Value

func (q *ExistsQuery) Value() any

type ExtendedStatsAgg

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

ExtendedStatsAgg computes extended statistics.

func (*ExtendedStatsAgg) Err

func (a *ExtendedStatsAgg) Err() error

func (*ExtendedStatsAgg) Field

func (a *ExtendedStatsAgg) Field() string

func (*ExtendedStatsAgg) Missing

func (a *ExtendedStatsAgg) Missing(m any) *ExtendedStatsAgg

Missing sets the value to use for missing fields.

func (*ExtendedStatsAgg) MissingValue

func (a *ExtendedStatsAgg) MissingValue() any

MissingValue returns the missing value if set.

func (*ExtendedStatsAgg) Name

func (a *ExtendedStatsAgg) Name() string

func (*ExtendedStatsAgg) Sigma

Sigma sets the sigma value for bounds.

func (*ExtendedStatsAgg) SigmaValue

func (a *ExtendedStatsAgg) SigmaValue() *float64

SigmaValue returns the sigma value if set.

func (*ExtendedStatsAgg) SubAggs

func (a *ExtendedStatsAgg) SubAggs() []Aggregation

func (*ExtendedStatsAgg) Type

func (a *ExtendedStatsAgg) Type() AggType

type FieldKind

type FieldKind uint8

FieldKind categorizes field types for validation.

const (
	// KindUnknown is an unrecognized field type.
	KindUnknown FieldKind = iota
	// KindString is a string field.
	KindString
	// KindInt is an integer field (int, int64, uint, etc.).
	KindInt
	// KindFloat is a floating-point field (float32, float64).
	KindFloat
	// KindBool is a boolean field.
	KindBool
	// KindTime is a time.Time field.
	KindTime
	// KindSlice is a slice field (excluding vector types).
	KindSlice
	// KindVector is a vector embedding field ([]float32, []float64).
	KindVector
)

type FieldSpec

type FieldSpec struct {
	Name string    // Resolved name (json tag or Go name).
	Type string    // Go type string.
	Kind FieldKind // Categorized type.
}

FieldSpec describes a single field in the schema.

type FilterAgg

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

FilterAgg creates a single filter bucket.

func (*FilterAgg) Err

func (a *FilterAgg) Err() error

Err returns any error in this aggregation or its filter.

func (*FilterAgg) Field

func (a *FilterAgg) Field() string

func (*FilterAgg) FilterQuery

func (a *FilterAgg) FilterQuery() Query

FilterQuery returns the filter query.

func (*FilterAgg) Name

func (a *FilterAgg) Name() string

func (*FilterAgg) SubAgg

func (a *FilterAgg) SubAgg(sub Aggregation) *FilterAgg

SubAgg adds a sub-aggregation.

func (*FilterAgg) SubAggs

func (a *FilterAgg) SubAggs() []Aggregation

func (*FilterAgg) Type

func (a *FilterAgg) Type() AggType

type FiltersAgg

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

FiltersAgg creates named filter buckets.

func (*FiltersAgg) Err

func (a *FiltersAgg) Err() error

Err returns any error in this aggregation or its filters.

func (*FiltersAgg) Field

func (a *FiltersAgg) Field() string

func (*FiltersAgg) Filter

func (a *FiltersAgg) Filter(name string, q Query) *FiltersAgg

Filter adds a named filter bucket.

func (*FiltersAgg) Filters

func (a *FiltersAgg) Filters() map[string]Query

Filters returns the named filters.

func (*FiltersAgg) Name

func (a *FiltersAgg) Name() string

func (*FiltersAgg) SubAgg

func (a *FiltersAgg) SubAgg(sub Aggregation) *FiltersAgg

SubAgg adds a sub-aggregation.

func (*FiltersAgg) SubAggs

func (a *FiltersAgg) SubAggs() []Aggregation

func (*FiltersAgg) Type

func (a *FiltersAgg) Type() AggType

type FuzzyQuery

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

FuzzyQuery matches documents using edit distance.

func (*FuzzyQuery) Boost

func (q *FuzzyQuery) Boost(b float64) *FuzzyQuery

Boost sets the relevance score multiplier.

func (*FuzzyQuery) BoostValue

func (q *FuzzyQuery) BoostValue() *float64

BoostValue returns the boost value if set.

func (*FuzzyQuery) Err

func (q *FuzzyQuery) Err() error

func (*FuzzyQuery) Field

func (q *FuzzyQuery) Field() string

func (*FuzzyQuery) Fuzziness

func (q *FuzzyQuery) Fuzziness(f string) *FuzzyQuery

Fuzziness sets the maximum edit distance.

func (*FuzzyQuery) FuzzinessValue

func (q *FuzzyQuery) FuzzinessValue() *string

FuzzinessValue returns the fuzziness value if set.

func (*FuzzyQuery) MaxExpansions

func (q *FuzzyQuery) MaxExpansions(m int) *FuzzyQuery

MaxExpansions sets the maximum number of terms to match.

func (*FuzzyQuery) MaxExpansionsValue

func (q *FuzzyQuery) MaxExpansionsValue() *int

MaxExpansionsValue returns the max_expansions value if set.

func (*FuzzyQuery) Op

func (q *FuzzyQuery) Op() Op

func (*FuzzyQuery) PrefixLength

func (q *FuzzyQuery) PrefixLength(p int) *FuzzyQuery

PrefixLength sets the number of initial characters that must match exactly.

func (*FuzzyQuery) PrefixLengthValue

func (q *FuzzyQuery) PrefixLengthValue() *int

PrefixLengthValue returns the prefix_length value if set.

func (*FuzzyQuery) Rewrite

func (q *FuzzyQuery) Rewrite(r string) *FuzzyQuery

Rewrite sets the rewrite method.

func (*FuzzyQuery) RewriteValue

func (q *FuzzyQuery) RewriteValue() *string

RewriteValue returns the rewrite value if set.

func (*FuzzyQuery) Transpositions

func (q *FuzzyQuery) Transpositions(t bool) *FuzzyQuery

Transpositions enables or disables transpositions.

func (*FuzzyQuery) TranspositionsValue

func (q *FuzzyQuery) TranspositionsValue() *bool

TranspositionsValue returns the transpositions value if set.

func (*FuzzyQuery) Value

func (q *FuzzyQuery) Value() any

type GeoBoundingBoxQuery

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

GeoBoundingBoxQuery matches documents within a bounding box.

func (*GeoBoundingBoxQuery) Boost

Boost sets the relevance score multiplier.

func (*GeoBoundingBoxQuery) BoostValue

func (q *GeoBoundingBoxQuery) BoostValue() *float64

BoostValue returns the boost value if set.

func (*GeoBoundingBoxQuery) BottomRight

func (q *GeoBoundingBoxQuery) BottomRight(lat, lon float64) *GeoBoundingBoxQuery

BottomRight sets the bottom-right corner of the bounding box.

func (*GeoBoundingBoxQuery) BottomRightLat

func (q *GeoBoundingBoxQuery) BottomRightLat() *float64

BottomRightLat returns the bottom-right latitude if set.

func (*GeoBoundingBoxQuery) BottomRightLon

func (q *GeoBoundingBoxQuery) BottomRightLon() *float64

BottomRightLon returns the bottom-right longitude if set.

func (*GeoBoundingBoxQuery) Err

func (q *GeoBoundingBoxQuery) Err() error

func (*GeoBoundingBoxQuery) Field

func (q *GeoBoundingBoxQuery) Field() string

func (*GeoBoundingBoxQuery) Op

func (q *GeoBoundingBoxQuery) Op() Op

func (*GeoBoundingBoxQuery) TopLeft

func (q *GeoBoundingBoxQuery) TopLeft(lat, lon float64) *GeoBoundingBoxQuery

TopLeft sets the top-left corner of the bounding box.

func (*GeoBoundingBoxQuery) TopLeftLat

func (q *GeoBoundingBoxQuery) TopLeftLat() *float64

TopLeftLat returns the top-left latitude if set.

func (*GeoBoundingBoxQuery) TopLeftLon

func (q *GeoBoundingBoxQuery) TopLeftLon() *float64

TopLeftLon returns the top-left longitude if set.

func (*GeoBoundingBoxQuery) Value

func (q *GeoBoundingBoxQuery) Value() any

type GeoDistanceQuery

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

GeoDistanceQuery matches documents within a radius from a point.

func (*GeoDistanceQuery) Boost

Boost sets the relevance score multiplier.

func (*GeoDistanceQuery) BoostValue

func (q *GeoDistanceQuery) BoostValue() *float64

BoostValue returns the boost value if set.

func (*GeoDistanceQuery) Distance

func (q *GeoDistanceQuery) Distance(d string) *GeoDistanceQuery

Distance sets the radius (e.g., "10km", "5mi").

func (*GeoDistanceQuery) DistanceType

func (q *GeoDistanceQuery) DistanceType(t string) *GeoDistanceQuery

DistanceType sets the distance calculation type ("arc" or "plane").

func (*GeoDistanceQuery) DistanceTypeValue

func (q *GeoDistanceQuery) DistanceTypeValue() *string

DistanceTypeValue returns the distance_type value if set.

func (*GeoDistanceQuery) DistanceValue

func (q *GeoDistanceQuery) DistanceValue() *string

DistanceValue returns the distance value if set.

func (*GeoDistanceQuery) Err

func (q *GeoDistanceQuery) Err() error

func (*GeoDistanceQuery) Field

func (q *GeoDistanceQuery) Field() string

func (*GeoDistanceQuery) Lat

func (q *GeoDistanceQuery) Lat() float64

Lat returns the latitude.

func (*GeoDistanceQuery) Lon

func (q *GeoDistanceQuery) Lon() float64

Lon returns the longitude.

func (*GeoDistanceQuery) Op

func (q *GeoDistanceQuery) Op() Op

func (*GeoDistanceQuery) Value

func (q *GeoDistanceQuery) Value() any

type HasChildQuery

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

HasChildQuery matches parents by child documents.

func (*HasChildQuery) ChildType

func (q *HasChildQuery) ChildType() string

ChildType returns the child type.

func (*HasChildQuery) Err

func (q *HasChildQuery) Err() error

Err returns any error in this query or its inner query.

func (*HasChildQuery) Field

func (q *HasChildQuery) Field() string

func (*HasChildQuery) IgnoreUnmapped

func (q *HasChildQuery) IgnoreUnmapped(b bool) *HasChildQuery

IgnoreUnmapped sets whether to ignore unmapped types.

func (*HasChildQuery) IgnoreUnmappedValue

func (q *HasChildQuery) IgnoreUnmappedValue() *bool

IgnoreUnmappedValue returns the ignore_unmapped value if set.

func (*HasChildQuery) InnerQuery

func (q *HasChildQuery) InnerQuery() Query

InnerQuery returns the inner query.

func (*HasChildQuery) MaxChildren

func (q *HasChildQuery) MaxChildren(n int) *HasChildQuery

MaxChildren sets the maximum number of children that must match.

func (*HasChildQuery) MaxChildrenValue

func (q *HasChildQuery) MaxChildrenValue() *int

MaxChildrenValue returns the max_children value if set.

func (*HasChildQuery) MinChildren

func (q *HasChildQuery) MinChildren(n int) *HasChildQuery

MinChildren sets the minimum number of children that must match.

func (*HasChildQuery) MinChildrenValue

func (q *HasChildQuery) MinChildrenValue() *int

MinChildrenValue returns the min_children value if set.

func (*HasChildQuery) Op

func (q *HasChildQuery) Op() Op

func (*HasChildQuery) ScoreMode

func (q *HasChildQuery) ScoreMode(m string) *HasChildQuery

ScoreMode sets how child scores affect parent score.

func (*HasChildQuery) ScoreModeValue

func (q *HasChildQuery) ScoreModeValue() *string

ScoreModeValue returns the score_mode value if set.

func (*HasChildQuery) Value

func (q *HasChildQuery) Value() any

type HasParentQuery

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

HasParentQuery matches children by parent documents.

func (*HasParentQuery) Err

func (q *HasParentQuery) Err() error

Err returns any error in this query or its inner query.

func (*HasParentQuery) Field

func (q *HasParentQuery) Field() string

func (*HasParentQuery) IgnoreUnmapped

func (q *HasParentQuery) IgnoreUnmapped(b bool) *HasParentQuery

IgnoreUnmapped sets whether to ignore unmapped types.

func (*HasParentQuery) IgnoreUnmappedValue

func (q *HasParentQuery) IgnoreUnmappedValue() *bool

IgnoreUnmappedValue returns the ignore_unmapped value if set.

func (*HasParentQuery) InnerQuery

func (q *HasParentQuery) InnerQuery() Query

InnerQuery returns the inner query.

func (*HasParentQuery) Op

func (q *HasParentQuery) Op() Op

func (*HasParentQuery) ParentType

func (q *HasParentQuery) ParentType() string

ParentType returns the parent type.

func (*HasParentQuery) Score

func (q *HasParentQuery) Score(b bool) *HasParentQuery

Score sets whether to include the parent score.

func (*HasParentQuery) ScoreValue

func (q *HasParentQuery) ScoreValue() *bool

ScoreValue returns the score value if set.

func (*HasParentQuery) Value

func (q *HasParentQuery) Value() any

type Highlight

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

Highlight represents highlight configuration for search results.

func NewHighlight

func NewHighlight() *Highlight

NewHighlight creates a new highlight configuration.

func (*Highlight) Encoder

func (h *Highlight) Encoder(e string) *Highlight

Encoder sets the encoder (default or html).

func (*Highlight) EncoderValue

func (h *Highlight) EncoderValue() *string

EncoderValue returns the encoder if set.

func (*Highlight) Err

func (h *Highlight) Err() error

Err returns any error in the highlight configuration.

func (*Highlight) Field

func (h *Highlight) Field(f HighlightField) *Highlight

Field adds a single field with custom configuration.

func (*Highlight) Fields

func (h *Highlight) Fields(names ...string) *Highlight

Fields adds fields to highlight.

func (*Highlight) FieldsValue

func (h *Highlight) FieldsValue() []HighlightField

FieldsValue returns the highlight fields.

func (*Highlight) FragmentSize

func (h *Highlight) FragmentSize(n int) *Highlight

FragmentSize sets the size of fragments.

func (*Highlight) FragmentSizeValue

func (h *Highlight) FragmentSizeValue() *int

FragmentSizeValue returns the fragment size if set.

func (*Highlight) Highlighter

func (h *Highlight) Highlighter(t string) *Highlight

Highlighter sets the highlighter type (unified, plain, or fvh).

func (*Highlight) HighlighterValue

func (h *Highlight) HighlighterValue() *string

HighlighterValue returns the highlighter type if set.

func (*Highlight) NumFragments

func (h *Highlight) NumFragments(n int) *Highlight

NumFragments sets the number of fragments.

func (*Highlight) NumFragmentsValue

func (h *Highlight) NumFragmentsValue() *int

NumFragmentsValue returns the number of fragments if set.

func (*Highlight) Order

func (h *Highlight) Order(o string) *Highlight

Order sets the fragment order (score or none).

func (*Highlight) OrderValue

func (h *Highlight) OrderValue() *string

OrderValue returns the order if set.

func (*Highlight) PostTags

func (h *Highlight) PostTags(tags ...string) *Highlight

PostTags sets the post-tags for highlighting.

func (*Highlight) PostTagsValue

func (h *Highlight) PostTagsValue() []string

PostTagsValue returns the post-tags.

func (*Highlight) PreTags

func (h *Highlight) PreTags(tags ...string) *Highlight

PreTags sets the pre-tags for highlighting.

func (*Highlight) PreTagsValue

func (h *Highlight) PreTagsValue() []string

PreTagsValue returns the pre-tags.

type HighlightField

type HighlightField struct {
	Name              string
	FragmentSize      *int
	NumFragments      *int
	PreTags           []string
	PostTags          []string
	HighlightQuery    Query
	MatchedFields     []string
	FragmentOffset    *int
	NoMatchSize       *int
	RequireFieldMatch *bool
}

HighlightField represents a single field highlight configuration.

type HighlightFieldBuilder

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

HighlightFieldBuilder builds a highlight field configuration.

func NewHighlightField

func NewHighlightField(name string) *HighlightFieldBuilder

NewHighlightField creates a new highlight field configuration.

func (*HighlightFieldBuilder) Build

Build returns the configured HighlightField.

func (*HighlightFieldBuilder) FragmentOffset

func (b *HighlightFieldBuilder) FragmentOffset(n int) *HighlightFieldBuilder

FragmentOffset sets the offset for fragments.

func (*HighlightFieldBuilder) FragmentSize

func (b *HighlightFieldBuilder) FragmentSize(n int) *HighlightFieldBuilder

FragmentSize sets the fragment size for this field.

func (*HighlightFieldBuilder) HighlightQuery

func (b *HighlightFieldBuilder) HighlightQuery(q Query) *HighlightFieldBuilder

HighlightQuery sets a custom query for highlighting.

func (*HighlightFieldBuilder) MatchedFields

func (b *HighlightFieldBuilder) MatchedFields(fields ...string) *HighlightFieldBuilder

MatchedFields sets fields to combine for highlighting.

func (*HighlightFieldBuilder) NoMatchSize

func (b *HighlightFieldBuilder) NoMatchSize(n int) *HighlightFieldBuilder

NoMatchSize sets the text size to show when no match.

func (*HighlightFieldBuilder) NumFragments

func (b *HighlightFieldBuilder) NumFragments(n int) *HighlightFieldBuilder

NumFragments sets the number of fragments for this field.

func (*HighlightFieldBuilder) PostTags

func (b *HighlightFieldBuilder) PostTags(tags ...string) *HighlightFieldBuilder

PostTags sets the post-tags for this field.

func (*HighlightFieldBuilder) PreTags

func (b *HighlightFieldBuilder) PreTags(tags ...string) *HighlightFieldBuilder

PreTags sets the pre-tags for this field.

func (*HighlightFieldBuilder) RequireFieldMatch

func (b *HighlightFieldBuilder) RequireFieldMatch(v bool) *HighlightFieldBuilder

RequireFieldMatch sets whether to require field match.

type HistogramAgg

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

HistogramAgg creates numeric buckets.

func (*HistogramAgg) Err

func (a *HistogramAgg) Err() error

func (*HistogramAgg) Field

func (a *HistogramAgg) Field() string

func (*HistogramAgg) Interval

func (a *HistogramAgg) Interval(i float64) *HistogramAgg

Interval sets the bucket interval.

func (*HistogramAgg) IntervalValue

func (a *HistogramAgg) IntervalValue() *float64

IntervalValue returns the interval if set.

func (*HistogramAgg) MinDocCount

func (a *HistogramAgg) MinDocCount(m int) *HistogramAgg

MinDocCount sets the minimum document count for a bucket.

func (*HistogramAgg) MinDocCountValue

func (a *HistogramAgg) MinDocCountValue() *int

MinDocCountValue returns the min_doc_count if set.

func (*HistogramAgg) Name

func (a *HistogramAgg) Name() string

func (*HistogramAgg) Offset

func (a *HistogramAgg) Offset(o float64) *HistogramAgg

Offset sets the bucket offset.

func (*HistogramAgg) OffsetValue

func (a *HistogramAgg) OffsetValue() *float64

OffsetValue returns the offset if set.

func (*HistogramAgg) SubAgg

func (a *HistogramAgg) SubAgg(sub Aggregation) *HistogramAgg

SubAgg adds a sub-aggregation.

func (*HistogramAgg) SubAggs

func (a *HistogramAgg) SubAggs() []Aggregation

func (*HistogramAgg) Type

func (a *HistogramAgg) Type() AggType

type IDsQuery

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

IDsQuery matches documents by their IDs.

func (*IDsQuery) Err

func (q *IDsQuery) Err() error

func (*IDsQuery) Field

func (q *IDsQuery) Field() string

func (*IDsQuery) IDValues

func (q *IDsQuery) IDValues() []string

IDValues returns the document IDs.

func (*IDsQuery) Op

func (q *IDsQuery) Op() Op

func (*IDsQuery) Value

func (q *IDsQuery) Value() any

type KnnQuery

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

KnnQuery performs k-nearest neighbors vector search.

func (*KnnQuery) Boost

func (q *KnnQuery) Boost(b float64) *KnnQuery

Boost sets the relevance score multiplier.

func (*KnnQuery) BoostValue

func (q *KnnQuery) BoostValue() *float64

BoostValue returns the boost value if set.

func (*KnnQuery) Err

func (q *KnnQuery) Err() error

Err returns any error in this query or its filter.

func (*KnnQuery) Field

func (q *KnnQuery) Field() string

func (*KnnQuery) Filter

func (q *KnnQuery) Filter(f Query) *KnnQuery

Filter sets a filter to apply to candidates.

func (*KnnQuery) FilterQuery

func (q *KnnQuery) FilterQuery() Query

FilterQuery returns the filter query if set.

func (*KnnQuery) K

func (q *KnnQuery) K(k int) *KnnQuery

K sets the number of nearest neighbors to return.

func (*KnnQuery) KValue

func (q *KnnQuery) KValue() *int

KValue returns the k value if set.

func (*KnnQuery) NumCandidates

func (q *KnnQuery) NumCandidates(n int) *KnnQuery

NumCandidates sets the number of candidates to consider.

func (*KnnQuery) NumCandidatesValue

func (q *KnnQuery) NumCandidatesValue() *int

NumCandidatesValue returns the num_candidates value if set.

func (*KnnQuery) Op

func (q *KnnQuery) Op() Op

func (*KnnQuery) Value

func (q *KnnQuery) Value() any

func (*KnnQuery) Vector

func (q *KnnQuery) Vector() []float32

Vector returns the query vector.

type MatchAllQuery

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

MatchAllQuery matches all documents.

func (*MatchAllQuery) Boost

func (q *MatchAllQuery) Boost(b float64) *MatchAllQuery

Boost sets the relevance score multiplier.

func (*MatchAllQuery) BoostValue

func (q *MatchAllQuery) BoostValue() *float64

BoostValue returns the boost value if set.

func (*MatchAllQuery) Err

func (q *MatchAllQuery) Err() error

func (*MatchAllQuery) Field

func (q *MatchAllQuery) Field() string

func (*MatchAllQuery) Op

func (q *MatchAllQuery) Op() Op

func (*MatchAllQuery) Value

func (q *MatchAllQuery) Value() any

type MatchNoneQuery

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

MatchNoneQuery matches no documents.

func (*MatchNoneQuery) Err

func (q *MatchNoneQuery) Err() error

func (*MatchNoneQuery) Field

func (q *MatchNoneQuery) Field() string

func (*MatchNoneQuery) Op

func (q *MatchNoneQuery) Op() Op

func (*MatchNoneQuery) Value

func (q *MatchNoneQuery) Value() any

type MatchPhrasePrefixQuery

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

MatchPhrasePrefixQuery matches a phrase prefix for autocomplete.

func (*MatchPhrasePrefixQuery) Analyzer

Analyzer sets the analyzer to use for the query.

func (*MatchPhrasePrefixQuery) AnalyzerValue

func (q *MatchPhrasePrefixQuery) AnalyzerValue() *string

AnalyzerValue returns the analyzer value if set.

func (*MatchPhrasePrefixQuery) Boost

Boost sets the relevance score multiplier.

func (*MatchPhrasePrefixQuery) BoostValue

func (q *MatchPhrasePrefixQuery) BoostValue() *float64

BoostValue returns the boost value if set.

func (*MatchPhrasePrefixQuery) Err

func (q *MatchPhrasePrefixQuery) Err() error

func (*MatchPhrasePrefixQuery) Field

func (q *MatchPhrasePrefixQuery) Field() string

func (*MatchPhrasePrefixQuery) MaxExpansions

func (q *MatchPhrasePrefixQuery) MaxExpansions(m int) *MatchPhrasePrefixQuery

MaxExpansions sets the maximum number of terms to match.

func (*MatchPhrasePrefixQuery) MaxExpansionsValue

func (q *MatchPhrasePrefixQuery) MaxExpansionsValue() *int

MaxExpansionsValue returns the max_expansions value if set.

func (*MatchPhrasePrefixQuery) Op

func (q *MatchPhrasePrefixQuery) Op() Op

func (*MatchPhrasePrefixQuery) Slop

Slop sets the number of positions allowed between terms.

func (*MatchPhrasePrefixQuery) SlopValue

func (q *MatchPhrasePrefixQuery) SlopValue() *int

SlopValue returns the slop value if set.

func (*MatchPhrasePrefixQuery) Value

func (q *MatchPhrasePrefixQuery) Value() any

type MatchPhraseQuery

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

MatchPhraseQuery matches an exact phrase.

func (*MatchPhraseQuery) Analyzer

func (q *MatchPhraseQuery) Analyzer(a string) *MatchPhraseQuery

Analyzer sets the analyzer to use for the query.

func (*MatchPhraseQuery) AnalyzerValue

func (q *MatchPhraseQuery) AnalyzerValue() *string

AnalyzerValue returns the analyzer value if set.

func (*MatchPhraseQuery) Boost

Boost sets the relevance score multiplier.

func (*MatchPhraseQuery) BoostValue

func (q *MatchPhraseQuery) BoostValue() *float64

BoostValue returns the boost value if set.

func (*MatchPhraseQuery) Err

func (q *MatchPhraseQuery) Err() error

func (*MatchPhraseQuery) Field

func (q *MatchPhraseQuery) Field() string

func (*MatchPhraseQuery) Op

func (q *MatchPhraseQuery) Op() Op

func (*MatchPhraseQuery) Slop

Slop sets the number of positions allowed between terms.

func (*MatchPhraseQuery) SlopValue

func (q *MatchPhraseQuery) SlopValue() *int

SlopValue returns the slop value if set.

func (*MatchPhraseQuery) Value

func (q *MatchPhraseQuery) Value() any

type MatchQuery

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

MatchQuery performs analyzed text search.

func (*MatchQuery) Analyzer

func (q *MatchQuery) Analyzer(a string) *MatchQuery

Analyzer sets the analyzer to use for the query.

func (*MatchQuery) AnalyzerValue

func (q *MatchQuery) AnalyzerValue() *string

AnalyzerValue returns the analyzer value if set.

func (*MatchQuery) Boost

func (q *MatchQuery) Boost(b float64) *MatchQuery

Boost sets the relevance score multiplier.

func (*MatchQuery) BoostValue

func (q *MatchQuery) BoostValue() *float64

BoostValue returns the boost value if set.

func (*MatchQuery) Err

func (q *MatchQuery) Err() error

func (*MatchQuery) Field

func (q *MatchQuery) Field() string

func (*MatchQuery) Fuzziness

func (q *MatchQuery) Fuzziness(f string) *MatchQuery

Fuzziness sets the edit distance for fuzzy matching ("AUTO", "0", "1", "2").

func (*MatchQuery) FuzzinessValue

func (q *MatchQuery) FuzzinessValue() *string

FuzzinessValue returns the fuzziness value if set.

func (*MatchQuery) Op

func (q *MatchQuery) Op() Op

func (*MatchQuery) Operator

func (q *MatchQuery) Operator(o string) *MatchQuery

Operator sets the boolean operator for terms ("and", "or").

func (*MatchQuery) OperatorValue

func (q *MatchQuery) OperatorValue() *string

OperatorValue returns the operator value if set.

func (*MatchQuery) Value

func (q *MatchQuery) Value() any

type MaxAgg

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

MaxAgg computes the maximum value.

func (*MaxAgg) Err

func (a *MaxAgg) Err() error

func (*MaxAgg) Field

func (a *MaxAgg) Field() string

func (*MaxAgg) Missing

func (a *MaxAgg) Missing(m any) *MaxAgg

Missing sets the value to use for missing fields.

func (*MaxAgg) MissingValue

func (a *MaxAgg) MissingValue() any

MissingValue returns the missing value if set.

func (*MaxAgg) Name

func (a *MaxAgg) Name() string

func (*MaxAgg) SubAggs

func (a *MaxAgg) SubAggs() []Aggregation

func (*MaxAgg) Type

func (a *MaxAgg) Type() AggType

type MaxBucketAgg

type MaxBucketAgg struct {
	PipelineAgg
}

MaxBucketAgg finds the maximum bucket value.

func (*MaxBucketAgg) Err

func (a *MaxBucketAgg) Err() error

func (*MaxBucketAgg) Field

func (a *MaxBucketAgg) Field() string

func (*MaxBucketAgg) Name

func (a *MaxBucketAgg) Name() string

func (*MaxBucketAgg) SubAggs

func (a *MaxBucketAgg) SubAggs() []Aggregation

func (*MaxBucketAgg) Type

func (a *MaxBucketAgg) Type() AggType

type MinAgg

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

MinAgg computes the minimum value.

func (*MinAgg) Err

func (a *MinAgg) Err() error

func (*MinAgg) Field

func (a *MinAgg) Field() string

func (*MinAgg) Missing

func (a *MinAgg) Missing(m any) *MinAgg

Missing sets the value to use for missing fields.

func (*MinAgg) MissingValue

func (a *MinAgg) MissingValue() any

MissingValue returns the missing value if set.

func (*MinAgg) Name

func (a *MinAgg) Name() string

func (*MinAgg) SubAggs

func (a *MinAgg) SubAggs() []Aggregation

func (*MinAgg) Type

func (a *MinAgg) Type() AggType

type MinBucketAgg

type MinBucketAgg struct {
	PipelineAgg
}

MinBucketAgg finds the minimum bucket value.

func (*MinBucketAgg) Err

func (a *MinBucketAgg) Err() error

func (*MinBucketAgg) Field

func (a *MinBucketAgg) Field() string

func (*MinBucketAgg) Name

func (a *MinBucketAgg) Name() string

func (*MinBucketAgg) SubAggs

func (a *MinBucketAgg) SubAggs() []Aggregation

func (*MinBucketAgg) Type

func (a *MinBucketAgg) Type() AggType

type MissingAgg

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

MissingAgg counts documents missing a field.

func (*MissingAgg) Err

func (a *MissingAgg) Err() error

func (*MissingAgg) Field

func (a *MissingAgg) Field() string

func (*MissingAgg) Name

func (a *MissingAgg) Name() string

func (*MissingAgg) SubAgg

func (a *MissingAgg) SubAgg(sub Aggregation) *MissingAgg

SubAgg adds a sub-aggregation.

func (*MissingAgg) SubAggs

func (a *MissingAgg) SubAggs() []Aggregation

func (*MissingAgg) Type

func (a *MissingAgg) Type() AggType

type MovingAvgAgg

type MovingAvgAgg struct {
	PipelineAgg
	// contains filtered or unexported fields
}

MovingAvgAgg computes a moving average.

func (*MovingAvgAgg) Err

func (a *MovingAvgAgg) Err() error

func (*MovingAvgAgg) Field

func (a *MovingAvgAgg) Field() string

func (*MovingAvgAgg) Model

func (a *MovingAvgAgg) Model(m string) *MovingAvgAgg

Model sets the smoothing model.

func (*MovingAvgAgg) ModelValue

func (a *MovingAvgAgg) ModelValue() *string

ModelValue returns the model if set.

func (*MovingAvgAgg) Name

func (a *MovingAvgAgg) Name() string

func (*MovingAvgAgg) Predict

func (a *MovingAvgAgg) Predict(p int) *MovingAvgAgg

Predict sets the number of predictions.

func (*MovingAvgAgg) PredictValue

func (a *MovingAvgAgg) PredictValue() *int

PredictValue returns the predict if set.

func (*MovingAvgAgg) SubAggs

func (a *MovingAvgAgg) SubAggs() []Aggregation

func (*MovingAvgAgg) Type

func (a *MovingAvgAgg) Type() AggType

func (*MovingAvgAgg) Window

func (a *MovingAvgAgg) Window(w int) *MovingAvgAgg

Window sets the window size.

func (*MovingAvgAgg) WindowValue

func (a *MovingAvgAgg) WindowValue() *int

WindowValue returns the window if set.

type MultiMatchQuery

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

MultiMatchQuery searches across multiple fields.

func (*MultiMatchQuery) Analyzer

func (q *MultiMatchQuery) Analyzer(a string) *MultiMatchQuery

Analyzer sets the analyzer to use for the query.

func (*MultiMatchQuery) AnalyzerValue

func (q *MultiMatchQuery) AnalyzerValue() *string

AnalyzerValue returns the analyzer value if set.

func (*MultiMatchQuery) Boost

Boost sets the relevance score multiplier.

func (*MultiMatchQuery) BoostValue

func (q *MultiMatchQuery) BoostValue() *float64

BoostValue returns the boost value if set.

func (*MultiMatchQuery) Err

func (q *MultiMatchQuery) Err() error

func (*MultiMatchQuery) Field

func (q *MultiMatchQuery) Field() string

func (*MultiMatchQuery) Fields

func (q *MultiMatchQuery) Fields() []string

Fields returns the fields to search.

func (*MultiMatchQuery) Fuzziness

func (q *MultiMatchQuery) Fuzziness(f string) *MultiMatchQuery

Fuzziness sets the edit distance for fuzzy matching.

func (*MultiMatchQuery) FuzzinessValue

func (q *MultiMatchQuery) FuzzinessValue() *string

FuzzinessValue returns the fuzziness value if set.

func (*MultiMatchQuery) Op

func (q *MultiMatchQuery) Op() Op

func (*MultiMatchQuery) Operator

func (q *MultiMatchQuery) Operator(o string) *MultiMatchQuery

Operator sets the boolean operator for terms.

func (*MultiMatchQuery) OperatorValue

func (q *MultiMatchQuery) OperatorValue() *string

OperatorValue returns the operator value if set.

func (*MultiMatchQuery) TieBreaker

func (q *MultiMatchQuery) TieBreaker(t float64) *MultiMatchQuery

TieBreaker sets the tie breaker for best_fields and most_fields types.

func (*MultiMatchQuery) TieBreakerValue

func (q *MultiMatchQuery) TieBreakerValue() *float64

TieBreakerValue returns the tie breaker value if set.

func (*MultiMatchQuery) Type

Type sets the multi-match type ("best_fields", "most_fields", "cross_fields", "phrase").

func (*MultiMatchQuery) TypeValue

func (q *MultiMatchQuery) TypeValue() *string

TypeValue returns the multi-match type if set.

func (*MultiMatchQuery) Value

func (q *MultiMatchQuery) Value() any

type NestedAgg

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

NestedAgg aggregates nested documents.

func (*NestedAgg) Err

func (a *NestedAgg) Err() error

func (*NestedAgg) Field

func (a *NestedAgg) Field() string

func (*NestedAgg) Name

func (a *NestedAgg) Name() string

func (*NestedAgg) Path

func (a *NestedAgg) Path() string

Path returns the nested path.

func (*NestedAgg) SubAgg

func (a *NestedAgg) SubAgg(sub Aggregation) *NestedAgg

SubAgg adds a sub-aggregation.

func (*NestedAgg) SubAggs

func (a *NestedAgg) SubAggs() []Aggregation

func (*NestedAgg) Type

func (a *NestedAgg) Type() AggType

type NestedQuery

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

NestedQuery queries nested object fields.

func (*NestedQuery) Err

func (q *NestedQuery) Err() error

Err returns any error in this query or its inner query.

func (*NestedQuery) Field

func (q *NestedQuery) Field() string

func (*NestedQuery) IgnoreUnmapped

func (q *NestedQuery) IgnoreUnmapped(b bool) *NestedQuery

IgnoreUnmapped sets whether to ignore unmapped paths.

func (*NestedQuery) IgnoreUnmappedValue

func (q *NestedQuery) IgnoreUnmappedValue() *bool

IgnoreUnmappedValue returns the ignore_unmapped value if set.

func (*NestedQuery) InnerQuery

func (q *NestedQuery) InnerQuery() Query

InnerQuery returns the inner query.

func (*NestedQuery) Op

func (q *NestedQuery) Op() Op

func (*NestedQuery) Path

func (q *NestedQuery) Path() string

Path returns the nested path.

func (*NestedQuery) ScoreMode

func (q *NestedQuery) ScoreMode(m string) *NestedQuery

ScoreMode sets how nested scores are combined ("avg", "sum", "min", "max", "none").

func (*NestedQuery) ScoreModeValue

func (q *NestedQuery) ScoreModeValue() *string

ScoreModeValue returns the score_mode value if set.

func (*NestedQuery) Value

func (q *NestedQuery) Value() any

type Op

type Op uint8

Op represents a query operator type.

const (
	// OpMatch is an analyzed text search query.
	OpMatch Op = iota
	// OpMatchPhrase matches an exact phrase.
	OpMatchPhrase
	// OpMatchPhrasePrefix matches a phrase prefix for autocomplete.
	OpMatchPhrasePrefix
	// OpMultiMatch searches across multiple fields.
	OpMultiMatch
	// OpQueryString parses Lucene query syntax.
	OpQueryString
	// OpSimpleQueryString parses user-friendly query syntax.
	OpSimpleQueryString

	// OpTerm matches an exact value.
	OpTerm
	// OpTerms matches multiple exact values.
	OpTerms
	// OpRange matches a numeric or date range.
	OpRange
	// OpPrefix matches a field prefix.
	OpPrefix
	// OpWildcard matches a wildcard pattern.
	OpWildcard
	// OpRegexp matches a regular expression.
	OpRegexp
	// OpFuzzy matches with edit distance tolerance.
	OpFuzzy
	// OpExists matches documents where the field exists.
	OpExists
	// OpIDs matches specific document IDs.
	OpIDs

	// OpBool combines queries with boolean logic.
	OpBool
	// OpBoosting demotes documents matching a negative query.
	OpBoosting
	// OpConstantScore wraps a query with a fixed score.
	OpConstantScore
	// OpDisMax returns the best match from multiple queries.
	OpDisMax

	// OpMatchAll matches all documents.
	OpMatchAll
	// OpMatchNone matches no documents.
	OpMatchNone
	// OpNested queries nested object fields.
	OpNested
	// OpHasChild matches parents by child documents.
	OpHasChild
	// OpHasParent matches children by parent documents.
	OpHasParent

	// OpKnn performs k-nearest neighbors vector search.
	OpKnn

	// OpGeoDistance matches documents within a radius.
	OpGeoDistance
	// OpGeoBoundingBox matches documents within a bounding box.
	OpGeoBoundingBox
)

type PercentilesAgg

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

PercentilesAgg computes percentile values.

func (*PercentilesAgg) Err

func (a *PercentilesAgg) Err() error

func (*PercentilesAgg) Field

func (a *PercentilesAgg) Field() string

func (*PercentilesAgg) Missing

func (a *PercentilesAgg) Missing(m any) *PercentilesAgg

Missing sets the value to use for missing fields.

func (*PercentilesAgg) MissingValue

func (a *PercentilesAgg) MissingValue() any

MissingValue returns the missing value if set.

func (*PercentilesAgg) Name

func (a *PercentilesAgg) Name() string

func (*PercentilesAgg) Percents

func (a *PercentilesAgg) Percents(p ...float64) *PercentilesAgg

Percents sets the percentiles to compute.

func (*PercentilesAgg) PercentsValue

func (a *PercentilesAgg) PercentsValue() []float64

PercentsValue returns the percents if set.

func (*PercentilesAgg) SubAggs

func (a *PercentilesAgg) SubAggs() []Aggregation

func (*PercentilesAgg) Type

func (a *PercentilesAgg) Type() AggType

type PipelineAgg

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

PipelineAgg is a base for pipeline aggregations.

func (*PipelineAgg) BucketsPath

func (a *PipelineAgg) BucketsPath() string

BucketsPath returns the buckets_path.

func (*PipelineAgg) Err

func (a *PipelineAgg) Err() error

func (*PipelineAgg) Field

func (a *PipelineAgg) Field() string

func (*PipelineAgg) Format

func (a *PipelineAgg) Format(f string) *PipelineAgg

Format sets the output format.

func (*PipelineAgg) FormatValue

func (a *PipelineAgg) FormatValue() *string

FormatValue returns the format if set.

func (*PipelineAgg) GapPolicy

func (a *PipelineAgg) GapPolicy(p string) *PipelineAgg

GapPolicy sets how to handle gaps in data.

func (*PipelineAgg) GapPolicyValue

func (a *PipelineAgg) GapPolicyValue() *string

GapPolicyValue returns the gap_policy if set.

func (*PipelineAgg) Name

func (a *PipelineAgg) Name() string

func (*PipelineAgg) SubAggs

func (a *PipelineAgg) SubAggs() []Aggregation

func (*PipelineAgg) Type

func (a *PipelineAgg) Type() AggType

type PrefixQuery

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

PrefixQuery matches documents with a field prefix.

func (*PrefixQuery) Boost

func (q *PrefixQuery) Boost(b float64) *PrefixQuery

Boost sets the relevance score multiplier.

func (*PrefixQuery) BoostValue

func (q *PrefixQuery) BoostValue() *float64

BoostValue returns the boost value if set.

func (*PrefixQuery) CaseInsensitive

func (q *PrefixQuery) CaseInsensitive(b bool) *PrefixQuery

CaseInsensitive enables case-insensitive matching.

func (*PrefixQuery) CaseInsensitiveValue

func (q *PrefixQuery) CaseInsensitiveValue() *bool

CaseInsensitiveValue returns the case_insensitive value if set.

func (*PrefixQuery) Err

func (q *PrefixQuery) Err() error

func (*PrefixQuery) Field

func (q *PrefixQuery) Field() string

func (*PrefixQuery) Op

func (q *PrefixQuery) Op() Op

func (*PrefixQuery) Rewrite

func (q *PrefixQuery) Rewrite(r string) *PrefixQuery

Rewrite sets the rewrite method.

func (*PrefixQuery) RewriteValue

func (q *PrefixQuery) RewriteValue() *string

RewriteValue returns the rewrite value if set.

func (*PrefixQuery) Value

func (q *PrefixQuery) Value() any

type Query

type Query interface {
	// Op returns the operator type for this query.
	Op() Op

	// Err returns any error associated with this query.
	// Errors are deferred until explicitly checked.
	Err() error
	// contains filtered or unexported methods
}

Query is the interface implemented by all query types.

type QueryStringQuery

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

QueryStringQuery parses Lucene query syntax.

func (*QueryStringQuery) AllowLeadingWildcard

func (q *QueryStringQuery) AllowLeadingWildcard(b bool) *QueryStringQuery

AllowLeadingWildcard enables or disables leading wildcards.

func (*QueryStringQuery) AllowLeadingWildcardValue

func (q *QueryStringQuery) AllowLeadingWildcardValue() *bool

AllowLeadingWildcardValue returns the allow_leading_wildcard value if set.

func (*QueryStringQuery) Analyzer

func (q *QueryStringQuery) Analyzer(a string) *QueryStringQuery

Analyzer sets the analyzer to use.

func (*QueryStringQuery) AnalyzerValue

func (q *QueryStringQuery) AnalyzerValue() *string

AnalyzerValue returns the analyzer value if set.

func (*QueryStringQuery) Boost

Boost sets the relevance score multiplier.

func (*QueryStringQuery) BoostValue

func (q *QueryStringQuery) BoostValue() *float64

BoostValue returns the boost value if set.

func (*QueryStringQuery) DefaultField

func (q *QueryStringQuery) DefaultField(f string) *QueryStringQuery

DefaultField sets the default field for terms without a field prefix.

func (*QueryStringQuery) DefaultFieldValue

func (q *QueryStringQuery) DefaultFieldValue() *string

DefaultFieldValue returns the default_field value if set.

func (*QueryStringQuery) DefaultOperator

func (q *QueryStringQuery) DefaultOperator(o string) *QueryStringQuery

DefaultOperator sets the default operator ("AND" or "OR").

func (*QueryStringQuery) DefaultOperatorValue

func (q *QueryStringQuery) DefaultOperatorValue() *string

DefaultOperatorValue returns the default_operator value if set.

func (*QueryStringQuery) Err

func (q *QueryStringQuery) Err() error

func (*QueryStringQuery) Field

func (q *QueryStringQuery) Field() string

func (*QueryStringQuery) Fuzziness

func (q *QueryStringQuery) Fuzziness(f string) *QueryStringQuery

Fuzziness sets the default fuzziness.

func (*QueryStringQuery) FuzzinessValue

func (q *QueryStringQuery) FuzzinessValue() *string

FuzzinessValue returns the fuzziness value if set.

func (*QueryStringQuery) Op

func (q *QueryStringQuery) Op() Op

func (*QueryStringQuery) Value

func (q *QueryStringQuery) Value() any

type RangeAgg

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

RangeAgg creates custom range buckets.

func (*RangeAgg) AddKeyedRange

func (a *RangeAgg) AddKeyedRange(key string, from, to any) *RangeAgg

AddKeyedRange adds a named range bucket.

func (*RangeAgg) AddRange

func (a *RangeAgg) AddRange(from, to any) *RangeAgg

AddRange adds a range bucket.

func (*RangeAgg) Err

func (a *RangeAgg) Err() error

func (*RangeAgg) Field

func (a *RangeAgg) Field() string

func (*RangeAgg) Keyed

func (a *RangeAgg) Keyed(k bool) *RangeAgg

Keyed sets whether to return buckets as a map.

func (*RangeAgg) KeyedValue

func (a *RangeAgg) KeyedValue() *bool

KeyedValue returns the keyed value if set.

func (*RangeAgg) Name

func (a *RangeAgg) Name() string

func (*RangeAgg) Ranges

func (a *RangeAgg) Ranges() []RangeSpec

Ranges returns the range specifications.

func (*RangeAgg) SubAgg

func (a *RangeAgg) SubAgg(sub Aggregation) *RangeAgg

SubAgg adds a sub-aggregation.

func (*RangeAgg) SubAggs

func (a *RangeAgg) SubAggs() []Aggregation

func (*RangeAgg) Type

func (a *RangeAgg) Type() AggType

type RangeQuery

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

RangeQuery matches documents within a range.

func (*RangeQuery) Boost

func (q *RangeQuery) Boost(b float64) *RangeQuery

Boost sets the relevance score multiplier.

func (*RangeQuery) BoostValue

func (q *RangeQuery) BoostValue() *float64

BoostValue returns the boost value if set.

func (*RangeQuery) Err

func (q *RangeQuery) Err() error

func (*RangeQuery) Field

func (q *RangeQuery) Field() string

func (*RangeQuery) Format

func (q *RangeQuery) Format(f string) *RangeQuery

Format sets the date format for parsing string values.

func (*RangeQuery) FormatValue

func (q *RangeQuery) FormatValue() *string

FormatValue returns the format value if set.

func (*RangeQuery) Gt

func (q *RangeQuery) Gt(v any) *RangeQuery

Gt sets the exclusive lower bound.

func (*RangeQuery) GtValue

func (q *RangeQuery) GtValue() any

GtValue returns the gt value if set.

func (*RangeQuery) Gte

func (q *RangeQuery) Gte(v any) *RangeQuery

Gte sets the inclusive lower bound.

func (*RangeQuery) GteValue

func (q *RangeQuery) GteValue() any

GteValue returns the gte value if set.

func (*RangeQuery) Lt

func (q *RangeQuery) Lt(v any) *RangeQuery

Lt sets the exclusive upper bound.

func (*RangeQuery) LtValue

func (q *RangeQuery) LtValue() any

LtValue returns the lt value if set.

func (*RangeQuery) Lte

func (q *RangeQuery) Lte(v any) *RangeQuery

Lte sets the inclusive upper bound.

func (*RangeQuery) LteValue

func (q *RangeQuery) LteValue() any

LteValue returns the lte value if set.

func (*RangeQuery) Op

func (q *RangeQuery) Op() Op

func (*RangeQuery) Value

func (q *RangeQuery) Value() any

type RangeSpec

type RangeSpec struct {
	Key  string
	From any
	To   any
}

RangeSpec defines a range bucket.

type RegexpQuery

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

RegexpQuery matches documents using regular expressions.

func (*RegexpQuery) Boost

func (q *RegexpQuery) Boost(b float64) *RegexpQuery

Boost sets the relevance score multiplier.

func (*RegexpQuery) BoostValue

func (q *RegexpQuery) BoostValue() *float64

BoostValue returns the boost value if set.

func (*RegexpQuery) CaseInsensitive

func (q *RegexpQuery) CaseInsensitive(b bool) *RegexpQuery

CaseInsensitive enables case-insensitive matching.

func (*RegexpQuery) CaseInsensitiveValue

func (q *RegexpQuery) CaseInsensitiveValue() *bool

CaseInsensitiveValue returns the case_insensitive value if set.

func (*RegexpQuery) Err

func (q *RegexpQuery) Err() error

func (*RegexpQuery) Field

func (q *RegexpQuery) Field() string

func (*RegexpQuery) Flags

func (q *RegexpQuery) Flags(f string) *RegexpQuery

Flags sets the regex flags.

func (*RegexpQuery) FlagsValue

func (q *RegexpQuery) FlagsValue() *string

FlagsValue returns the flags value if set.

func (*RegexpQuery) Op

func (q *RegexpQuery) Op() Op

func (*RegexpQuery) Rewrite

func (q *RegexpQuery) Rewrite(r string) *RegexpQuery

Rewrite sets the rewrite method.

func (*RegexpQuery) RewriteValue

func (q *RegexpQuery) RewriteValue() *string

RewriteValue returns the rewrite value if set.

func (*RegexpQuery) Value

func (q *RegexpQuery) Value() any

type Renderer

type Renderer interface {
	// Render converts a complete search request to JSON.
	Render(search *Search) ([]byte, error)

	// RenderQuery converts a single query to JSON.
	RenderQuery(query Query) ([]byte, error)

	// RenderAggs converts aggregations to JSON.
	RenderAggs(aggs []Aggregation) ([]byte, error)
}

Renderer converts queries and search requests to JSON.

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

Search represents a complete search request.

func NewSearch

func NewSearch() *Search

NewSearch creates a new search request builder.

func (*Search) Aggs

func (s *Search) Aggs(aggs ...Aggregation) *Search

Aggs adds aggregations to the search.

func (*Search) AggsValue

func (s *Search) AggsValue() []Aggregation

AggsValue returns the aggregations.

func (*Search) Err

func (s *Search) Err() error

Err returns any error in the search request.

func (*Search) From

func (s *Search) From(n int) *Search

From sets the starting offset for results.

func (*Search) FromValue

func (s *Search) FromValue() *int

FromValue returns the from offset if set.

func (*Search) Highlight

func (s *Search) Highlight(h *Highlight) *Search

Highlight sets the highlight configuration.

func (*Search) HighlightValue

func (s *Search) HighlightValue() *Highlight

HighlightValue returns the highlight configuration.

func (*Search) MinScore

func (s *Search) MinScore(score float64) *Search

MinScore sets the minimum score threshold.

func (*Search) MinScoreValue

func (s *Search) MinScoreValue() *float64

MinScoreValue returns the minimum score if set.

func (*Search) Query

func (s *Search) Query(q Query) *Search

Query sets the query for the search.

func (*Search) QueryValue

func (s *Search) QueryValue() Query

QueryValue returns the query.

func (*Search) Size

func (s *Search) Size(n int) *Search

Size sets the number of hits to return.

func (*Search) SizeValue

func (s *Search) SizeValue() *int

SizeValue returns the size if set.

func (*Search) Sort

func (s *Search) Sort(fields ...SortField) *Search

Sort adds sort fields to the search.

func (*Search) SortValue

func (s *Search) SortValue() []SortField

SortValue returns the sort fields.

func (*Search) Source

func (s *Search) Source(fields ...string) *Search

Source sets the fields to include in _source.

func (*Search) SourceExcludes

func (s *Search) SourceExcludes(fields ...string) *Search

SourceExcludes sets fields to exclude from _source.

func (*Search) SourceExcludesValue

func (s *Search) SourceExcludesValue() []string

SourceExcludesValue returns the source excludes.

func (*Search) SourceIncludes

func (s *Search) SourceIncludes(fields ...string) *Search

SourceIncludes sets fields to include in _source.

func (*Search) SourceIncludesValue

func (s *Search) SourceIncludesValue() []string

SourceIncludesValue returns the source includes.

func (*Search) Timeout

func (s *Search) Timeout(t string) *Search

Timeout sets the search timeout.

func (*Search) TimeoutValue

func (s *Search) TimeoutValue() *string

TimeoutValue returns the timeout if set.

func (*Search) TrackTotalHits

func (s *Search) TrackTotalHits(v any) *Search

TrackTotalHits sets whether to track the total number of hits. Pass true for accurate count, false for bounded count, or an int for a threshold.

func (*Search) TrackTotalHitsValue

func (s *Search) TrackTotalHitsValue() any

TrackTotalHitsValue returns the track_total_hits value.

type SimpleQueryStringQuery

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

SimpleQueryStringQuery parses user-friendly query syntax.

func (*SimpleQueryStringQuery) Analyzer

Analyzer sets the analyzer to use.

func (*SimpleQueryStringQuery) AnalyzerValue

func (q *SimpleQueryStringQuery) AnalyzerValue() *string

AnalyzerValue returns the analyzer value if set.

func (*SimpleQueryStringQuery) Boost

Boost sets the relevance score multiplier.

func (*SimpleQueryStringQuery) BoostValue

func (q *SimpleQueryStringQuery) BoostValue() *float64

BoostValue returns the boost value if set.

func (*SimpleQueryStringQuery) DefaultOperator

func (q *SimpleQueryStringQuery) DefaultOperator(o string) *SimpleQueryStringQuery

DefaultOperator sets the default operator ("AND" or "OR").

func (*SimpleQueryStringQuery) DefaultOperatorValue

func (q *SimpleQueryStringQuery) DefaultOperatorValue() *string

DefaultOperatorValue returns the default_operator value if set.

func (*SimpleQueryStringQuery) Err

func (q *SimpleQueryStringQuery) Err() error

func (*SimpleQueryStringQuery) Field

func (q *SimpleQueryStringQuery) Field() string

func (*SimpleQueryStringQuery) Fields

Fields sets the fields to search.

func (*SimpleQueryStringQuery) FieldsValue

func (q *SimpleQueryStringQuery) FieldsValue() []string

FieldsValue returns the fields value.

func (*SimpleQueryStringQuery) Flags

Flags sets the enabled query features.

func (*SimpleQueryStringQuery) FlagsValue

func (q *SimpleQueryStringQuery) FlagsValue() *string

FlagsValue returns the flags value if set.

func (*SimpleQueryStringQuery) Op

func (q *SimpleQueryStringQuery) Op() Op

func (*SimpleQueryStringQuery) Value

func (q *SimpleQueryStringQuery) Value() any

type SortField

type SortField struct {
	Field string
	Order string // "asc" or "desc".
}

SortField represents a sort specification.

type Spec

type Spec struct {
	Fields []FieldSpec
}

Spec holds the extracted schema for a type.

type StatsAgg

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

StatsAgg computes basic statistics.

func (*StatsAgg) Err

func (a *StatsAgg) Err() error

func (*StatsAgg) Field

func (a *StatsAgg) Field() string

func (*StatsAgg) Missing

func (a *StatsAgg) Missing(m any) *StatsAgg

Missing sets the value to use for missing fields.

func (*StatsAgg) MissingValue

func (a *StatsAgg) MissingValue() any

MissingValue returns the missing value if set.

func (*StatsAgg) Name

func (a *StatsAgg) Name() string

func (*StatsAgg) SubAggs

func (a *StatsAgg) SubAggs() []Aggregation

func (*StatsAgg) Type

func (a *StatsAgg) Type() AggType

type SumAgg

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

SumAgg computes the sum of values.

func (*SumAgg) Err

func (a *SumAgg) Err() error

func (*SumAgg) Field

func (a *SumAgg) Field() string

func (*SumAgg) Missing

func (a *SumAgg) Missing(m any) *SumAgg

Missing sets the value to use for missing fields.

func (*SumAgg) MissingValue

func (a *SumAgg) MissingValue() any

MissingValue returns the missing value if set.

func (*SumAgg) Name

func (a *SumAgg) Name() string

func (*SumAgg) SubAggs

func (a *SumAgg) SubAggs() []Aggregation

func (*SumAgg) Type

func (a *SumAgg) Type() AggType

type SumBucketAgg

type SumBucketAgg struct {
	PipelineAgg
}

SumBucketAgg computes the sum of bucket values.

func (*SumBucketAgg) Err

func (a *SumBucketAgg) Err() error

func (*SumBucketAgg) Field

func (a *SumBucketAgg) Field() string

func (*SumBucketAgg) Name

func (a *SumBucketAgg) Name() string

func (*SumBucketAgg) SubAggs

func (a *SumBucketAgg) SubAggs() []Aggregation

func (*SumBucketAgg) Type

func (a *SumBucketAgg) Type() AggType

type TermQuery

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

TermQuery matches documents with an exact value.

func (*TermQuery) Boost

func (q *TermQuery) Boost(b float64) *TermQuery

Boost sets the relevance score multiplier.

func (*TermQuery) BoostValue

func (q *TermQuery) BoostValue() *float64

BoostValue returns the boost value if set.

func (*TermQuery) Err

func (q *TermQuery) Err() error

func (*TermQuery) Field

func (q *TermQuery) Field() string

func (*TermQuery) Op

func (q *TermQuery) Op() Op

func (*TermQuery) Value

func (q *TermQuery) Value() any

type TermsAgg

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

TermsAgg groups documents by field value.

func (*TermsAgg) Err

func (a *TermsAgg) Err() error

func (*TermsAgg) Field

func (a *TermsAgg) Field() string

func (*TermsAgg) MinDocCount

func (a *TermsAgg) MinDocCount(m int) *TermsAgg

MinDocCount sets the minimum document count for a bucket.

func (*TermsAgg) MinDocCountValue

func (a *TermsAgg) MinDocCountValue() *int

MinDocCountValue returns the min_doc_count if set.

func (*TermsAgg) Name

func (a *TermsAgg) Name() string

func (*TermsAgg) Order

func (a *TermsAgg) Order(field, dir string) *TermsAgg

Order sets the bucket sort order.

func (*TermsAgg) OrderValue

func (a *TermsAgg) OrderValue() map[string]string

OrderValue returns the order if set.

func (*TermsAgg) Size

func (a *TermsAgg) Size(s int) *TermsAgg

Size sets the maximum number of buckets to return.

func (*TermsAgg) SizeValue

func (a *TermsAgg) SizeValue() *int

SizeValue returns the size if set.

func (*TermsAgg) SubAgg

func (a *TermsAgg) SubAgg(sub Aggregation) *TermsAgg

SubAgg adds a sub-aggregation.

func (*TermsAgg) SubAggs

func (a *TermsAgg) SubAggs() []Aggregation

func (*TermsAgg) Type

func (a *TermsAgg) Type() AggType

type TermsQuery

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

TermsQuery matches documents with any of the specified values.

func (*TermsQuery) Boost

func (q *TermsQuery) Boost(b float64) *TermsQuery

Boost sets the relevance score multiplier.

func (*TermsQuery) BoostValue

func (q *TermsQuery) BoostValue() *float64

BoostValue returns the boost value if set.

func (*TermsQuery) Err

func (q *TermsQuery) Err() error

func (*TermsQuery) Field

func (q *TermsQuery) Field() string

func (*TermsQuery) Op

func (q *TermsQuery) Op() Op

func (*TermsQuery) Value

func (q *TermsQuery) Value() any

func (*TermsQuery) Values

func (q *TermsQuery) Values() []any

Values returns the term values.

type TopHitsAgg

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

TopHitsAgg returns top matching documents.

func (*TopHitsAgg) Err

func (a *TopHitsAgg) Err() error

func (*TopHitsAgg) Field

func (a *TopHitsAgg) Field() string

func (*TopHitsAgg) From

func (a *TopHitsAgg) From(f int) *TopHitsAgg

From sets the offset.

func (*TopHitsAgg) FromValue

func (a *TopHitsAgg) FromValue() *int

FromValue returns the from if set.

func (*TopHitsAgg) Name

func (a *TopHitsAgg) Name() string

func (*TopHitsAgg) Size

func (a *TopHitsAgg) Size(s int) *TopHitsAgg

Size sets the number of hits to return.

func (*TopHitsAgg) SizeValue

func (a *TopHitsAgg) SizeValue() *int

SizeValue returns the size if set.

func (*TopHitsAgg) Sort

func (a *TopHitsAgg) Sort(field, order string) *TopHitsAgg

Sort adds a sort field.

func (*TopHitsAgg) SortValue

func (a *TopHitsAgg) SortValue() []SortField

SortValue returns the sort fields.

func (*TopHitsAgg) Source

func (a *TopHitsAgg) Source(fields ...string) *TopHitsAgg

Source sets the fields to return.

func (*TopHitsAgg) SourceValue

func (a *TopHitsAgg) SourceValue() []string

SourceValue returns the source fields.

func (*TopHitsAgg) SubAggs

func (a *TopHitsAgg) SubAggs() []Aggregation

func (*TopHitsAgg) Type

func (a *TopHitsAgg) Type() AggType

type WildcardQuery

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

WildcardQuery matches documents using wildcard patterns.

func (*WildcardQuery) Boost

func (q *WildcardQuery) Boost(b float64) *WildcardQuery

Boost sets the relevance score multiplier.

func (*WildcardQuery) BoostValue

func (q *WildcardQuery) BoostValue() *float64

BoostValue returns the boost value if set.

func (*WildcardQuery) CaseInsensitive

func (q *WildcardQuery) CaseInsensitive(b bool) *WildcardQuery

CaseInsensitive enables case-insensitive matching.

func (*WildcardQuery) CaseInsensitiveValue

func (q *WildcardQuery) CaseInsensitiveValue() *bool

CaseInsensitiveValue returns the case_insensitive value if set.

func (*WildcardQuery) Err

func (q *WildcardQuery) Err() error

func (*WildcardQuery) Field

func (q *WildcardQuery) Field() string

func (*WildcardQuery) Op

func (q *WildcardQuery) Op() Op

func (*WildcardQuery) Rewrite

func (q *WildcardQuery) Rewrite(r string) *WildcardQuery

Rewrite sets the rewrite method.

func (*WildcardQuery) RewriteValue

func (q *WildcardQuery) RewriteValue() *string

RewriteValue returns the rewrite value if set.

func (*WildcardQuery) Value

func (q *WildcardQuery) Value() any

Directories

Path Synopsis
Package elasticsearch provides an Elasticsearch-specific query renderer.
Package elasticsearch provides an Elasticsearch-specific query renderer.
internal
marshal
Package marshal provides typed JSON marshaling for Elasticsearch/OpenSearch queries.
Package marshal provides typed JSON marshaling for Elasticsearch/OpenSearch queries.
Package opensearch provides an OpenSearch-specific query renderer.
Package opensearch provides an OpenSearch-specific query renderer.

Jump to

Keyboard shortcuts

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