search

package
v0.0.0-...-5978c11 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package search contains types for constructing queries in Elasticsearch

Index

Constants

View Source
const DefaultBoost = float64(0)

Variables

View Source
var (
	ErrFieldRequired     = errors.New("error: field is required")
	ErrValueRequired     = errors.New("error: value is required")
	ErrQueryRequired     = errors.New("error: query is required")
	ErrInvalidSourceType = errors.New("error: invalid source type")
	ErrInvalidRewrite    = errors.New("error: invalid rewrite value")
	ErrFieldExists       = errors.New("error: field exists")
	ErrTypeExists        = errors.New("error: type exists")
)
View Source
var DefaultBuilder = Builder{}
View Source
var TypeHandlers = map[Type]func() Rule{
	TypePrefix:  func() Rule { return &PrefixRule{} },
	TypeMatch:   func() Rule { return &MatchRule{} },
	TypeBoolean: func() Rule { return &BooleanRule{} },
	TypeTerm:    func() Rule { return &TermRule{} },
}

Functions

func NewIndicesBoost

func NewIndicesBoost() map[string]float64

Types

type AllOf

type AllOf struct {
}

func (AllOf) Rule

func (ao AllOf) Rule() (Rule, error)

func (AllOf) Type

func (ao AllOf) Type() Type

type AnalyzerParam

type AnalyzerParam struct {
	AnalyzerValue string `json:"analyzer,omitempty" bson:"analyzer,omitempty"`
}

AnalyzerParam is a query mixin that adds the analyzer param

Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the <field>. If no analyzer is mapped, the index’s default analyzer is used. (Optional)

https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis.html

func (AnalyzerParam) Analyzer

func (a AnalyzerParam) Analyzer() string

Analyzer used to convert the text in the query value into tokens. Defaults to the index-time analyzer mapped for the <field>. If no analyzer is mapped, the index’s default analyzer is used. (Optional)

func (*AnalyzerParam) SetAnalyzer

func (a *AnalyzerParam) SetAnalyzer(v string)

SetAnalyzer sets the Analyzer value to v

type AutoGenerateSynonymsPhraseQueryParam

type AutoGenerateSynonymsPhraseQueryParam struct {
	AutoGenerateSynonymsPhraseQueryValue *bool `bson:"auto_generate_synonyms_phrase_query,omitempty" json:"auto_generate_synonyms_phrase_query,omitempty"`
}

func (AutoGenerateSynonymsPhraseQueryParam) AutoGenerateSynonymsPhraseQuery

func (agspq AutoGenerateSynonymsPhraseQueryParam) AutoGenerateSynonymsPhraseQuery() bool

AutoGenerateSynonymsPhraseQuery determines if match phrase queries are automatically created for multi-term synonyms. Defaults to true.

func (*AutoGenerateSynonymsPhraseQueryParam) SetAutoGenerateSynonymsPhraseQuery

func (agspq *AutoGenerateSynonymsPhraseQueryParam) SetAutoGenerateSynonymsPhraseQuery(v bool)

SetAutoGenerateSynonymsPhraseQuery sets AutoGenerateSynonymsPhraseQueryValue to v

type Boolean

type Boolean struct {
}

type BooleanQuery

type BooleanQuery struct {
}

BooleanQuery is a query that matches documents matching boolean combinations of other queries. The bool query maps to Lucene BooleanQuery. It is built using one or more boolean clauses, each clause with a typed occurrence.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html

type BooleanRule

type BooleanRule struct {
}

func (BooleanRule) Type

func (b BooleanRule) Type() Type

type BoostParam

type BoostParam struct {
	BoostValue *float64 `bson:"boost,omitempty" json:"boost,omitempty"`
}

func (BoostParam) Boost

func (b BoostParam) Boost() float64

func (*BoostParam) SetBoost

func (b *BoostParam) SetBoost(v float64)

type Builder

type Builder struct {
	Defaults *Search
}

func (Builder) Build

func (b Builder) Build(fn func(s *Search) (*Search, error)) (*Search, error)

type CaseInsensitiveParam

type CaseInsensitiveParam struct {
	CaseInsensitiveValue *bool `json:"case_insensitive,omitempty" bson:"case_insensitive,omitempty"`
}

CaseInsensitiveParam is a query mixin that adds the case_insensitive param

(Optional, Boolean) Allows ASCII case insensitive matching of the value with the indexed field values when set to true. Default is false which means the case sensitivity of matching depends on the underlying field’s mapping.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html

func (CaseInsensitiveParam) CaseInsensitive

func (ci CaseInsensitiveParam) CaseInsensitive() bool

func (CaseInsensitiveParam) Default

func (ci CaseInsensitiveParam) Default() bool

func (*CaseInsensitiveParam) SetCaseInsensitive

func (ci *CaseInsensitiveParam) SetCaseInsensitive(v bool)

type Clause

type Clause struct {
	Type Type
	Rule Rule
}

func (Clause) MarshalBSON

func (c Clause) MarshalBSON() ([]byte, error)

func (Clause) MarshalJSON

func (c Clause) MarshalJSON() ([]byte, error)

func (*Clause) UnmarshalBSON

func (c *Clause) UnmarshalBSON(data []byte) error

func (*Clause) UnmarshalJSON

func (c *Clause) UnmarshalJSON(data []byte) error

type DocValueFields

type DocValueFields Fields

DocValueFields is used to return doc values for one or more fields in the search response.

(Optional, array of strings and objects) Array of wildcard (*) patterns. The request returns doc values for field names matching these patterns in the hits.fields property of the response. You can use the docvalue_fields parameter to return doc values for one or more fields in the search response.

Doc values store the same values as the _source but in an on-disk, column-based structure that’s optimized for sorting and aggregations. Since each field is stored separately, Elasticsearch only reads the field values that were requested and can avoid loading the whole document _source.

Doc values are stored for supported fields by default. However, doc values are not supported for text or text_annotated fields.

The following search request uses the docvalue_fields parameter to retrieve doc values for the user.id field, all fields starting with http.response., and the @timestamp field:

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-fields.html#docvalue-fields

See also:

https://www.elastic.co/guide/en/elasticsearch/reference/current/doc-values.html

func (DocValueFields) Clone

func (f DocValueFields) Clone() DocValueFields

type DynamicNumber

type DynamicNumber dynamic.Number

func Number

func Number(v interface{}) *DynamicNumber

Number returns a new DynamicNumber It panics if v can not be set to a dynamic.Number

see https://github.com/chanced/dynamic/blob/main/number.go

type Exists

type Exists struct {
	Field string `json:"field" bson:"field"`
}

Exists returns documents that contain an indexed value for a field.

An indexed value may not exist for a document’s field due to a variety of reasons:

  • The field in the source JSON is null or []

  • The field has "index" : false set in the mapping

  • The length of the field value exceeded an ignore_above setting in the

mapping

  • The field value was malformed and ignore_malformed was defined in the

mapping

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html

type ExistsQuery

type ExistsQuery struct {
	ExistsValue *Exists `json:"exists,omitempty" bson:"exists,omitempty"`
}

ExistsQuery returns documents that contain an indexed value for a field.

An indexed value may not exist for a document’s field due to a variety of reasons:

  • The field in the source JSON is null or []

  • The field has "index" : false set in the mapping

  • The length of the field value exceeded an ignore_above setting in the

mapping

  • The field value was malformed and ignore_malformed was defined in the

mapping

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html

func (*ExistsQuery) SetExistsField

func (e *ExistsQuery) SetExistsField(field string)

type Field

type Field struct {
	// (Required, string) Wildcard pattern. The request returns doc values for
	// field names matching this pattern.
	Field string `bson:"field" json:"field"`

	// (Optional, string) Format in which the doc values are returned.
	//
	// For date fields, you can specify a date date format. For numeric fields
	// fields, you can specify a DecimalFormat pattern.
	//
	// For other field data types, this parameter is not supported.
	Format string `bson:"format,omitempty" json:"format,omitempty"`
}

func (Field) MarshalJSON

func (f Field) MarshalJSON() ([]byte, error)

func (*Field) UnmarshalJSON

func (f *Field) UnmarshalJSON(data []byte) error

type Fields

type Fields []Field

Fields allows for retrieving a list of document fields in the search response. It consults both the document _source and the index mappings to return each value in a standardized way that matches its mapping type. By default, date fields are formatted according to the date format parameter in their mappings. You can also use the fields parameter to retrieve runtime field values.

(Optional, array of strings and objects) Array of wildcard (*) patterns. The request returns values for field names matching these patterns in the hits.fields property of the response.

You can specify items in the array as a string or object. See Fields for more details.

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-fields.html#search-fields-param

func (Fields) Clone

func (f Fields) Clone() Fields

type FormatParam

type FormatParam struct {
	FormatValue string `bson:"format,omitempty" json:"format,omitempty"`
}

FormatParam is a mixin that adds the format parameter to mappings

In JSON documents, dates are represented as strings. Elasticsearch uses a set of preconfigured formats to recognize and parse these strings into a long value representing milliseconds-since-the-epoch in UTC.

Besides the built-in formats, custom formats can be specified using the familiar yyyy/MM/dd syntax

"epoch_millis"

A formatter for the number of milliseconds since the epoch. Note, that this timestamp is subject to the limits of a Java Long.MIN_VALUE and Long.MAX_VALUE.

"epoch_second"

A formatter for the number of seconds since the epoch. Note, that this timestamp is subject to the limits of a Java Long.MIN_VALUE and Long. MAX_VALUE divided by 1000 (the number of milliseconds in a second).

"date_optional_time" || "strict_date_optional_time"

A generic ISO datetime parser, where the date must include the year at a minimum, and the time (separated by T), is optional. Examples: "yyyy-MM-dd'T'HH:mm:ss.SSSZ" || "yyyy-MM-dd"

"strict_date_optional_time_nanos"

A generic ISO datetime parser, where the date must include the year at a minimum, and the time (separated by T), is optional. The fraction of a second part has a nanosecond resolution. Examples: yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ or yyyy-MM-dd.

"basic_date"

A basic formatter for a full date as four digit year, two digit month of year, and two digit day of month: yyyyMMdd.

"basic_date_time"

A basic formatter that combines a basic date and time, separated by a T: yyyyMMdd'T'HHmmss.SSSZ.

"basic_date_time_no_millis"

A basic formatter that combines a basic date and time without millis, separated by a T: yyyyMMdd'T'HHmmssZ.

"basic_ordinal_date"

A formatter for a full ordinal date, using a four digit year and three digit dayOfYear: yyyyDDD.

"basic_ordinal_date_time"

A formatter for a full ordinal date and time, using a four digit year and three digit dayOfYear: yyyyDDD'T'HHmmss.SSSZ.

"basic_ordinal_date_time_no_millis"

A formatter for a full ordinal date and time without millis, using a four digit year and three digit dayOfYear: yyyyDDD'T'HHmmssZ.

"basic_time"

A basic formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, three digit millis, and time zone offset: HHmmss.SSSZ.

"basic_time_no_millis"

A basic formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and time zone offset: HHmmssZ.

"basic_t_time"

A basic formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, three digit millis, and time zone off set prefixed by T: 'T'HHmmss.SSSZ.

"basic_t_time_no_millis"

A basic formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and time zone offset prefixed by T: 'T'HHmmssZ.

"basic_week_date" || "strict_basic_week_date"

A basic formatter for a full date as four digit weekyear, two digit week of weekyear, and one digit day of week: xxxx'W'wwe.

"basic_week_date_time" || "strict_basic_week_date_time"

A basic formatter that combines a basic weekyear date and time, separated by a T: xxxx'W'wwe'T'HHmmss.SSSZ.

"basic_week_date_time_no_millis" || "strict_basic_week_date_time_no_millis"

A basic formatter that combines a basic weekyear date and time without millis, separated by a T: xxxx'W'wwe'T'HHmmssZ.

"date" || "strict_date"

A formatter for a full date as four digit year, two digit month of year, and two digit day of month: yyyy-MM-dd.

"date_hour" || "strict_date_hour"

A formatter that combines a full date and two digit hour of day: yyyy-MM-dd'T'HH.

"date_hour_minute" || "strict_date_hour_minute"

A formatter that combines a full date, two digit hour of day, and two digit minute of hour: yyyy-MM-dd'T'HH:mm.

"date_hour_minute_second" || "strict_date_hour_minute_second"

A formatter that combines a full date, two digit hour of day, two digit minute of hour, and two digit second of minute: yyyy-MM-dd'T'HH:mm:ss.

"date_hour_minute_second_fraction" || "strict_date_hour_minute_second_fraction"

A formatter that combines a full date, two digit hour of day, two digit minute of hour, two digit second of minute, and three digit fraction of second: yyyy-MM-dd'T'HH:mm:ss.SSS.

"date_hour_minute_second_millis" || "strict_date_hour_minute_second_millis" A formatter that combines a full date, two digit hour of day, two digit minute of hour, two digit second of minute, and three digit fraction of second: yyyy-MM-dd'T'HH:mm:ss.SSS.

"date_time" || "strict_date_time"

A formatter that combines a full date and time, separated by a T: yyyy-MM-dd'T'HH:mm:ss.SSSZZ.

"date_time_no_millis" || "strict_date_time_no_millis" A formatter that combines a full date and time without millis, separated by a T: yyyy-MM-dd'T'HH:mm:ssZZ.

"hour" || "strict_hour" A formatter for a two digit hour of day: HH

"hour_minute" || "strict_hour_minute"

A formatter for a two digit hour of day and two digit minute of hour: HH:mm.

"hour_minute_second" || "strict_hour_minute_second"

A formatter for a two digit hour of day, two digit minute of hour, and two digit second of minute: HH:mm:ss.

"hour_minute_second_fraction" || "strict_hour_minute_second_fraction"

A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and three digit fraction of second: HH:mm:ss.SSS.

"hour_minute_second_millis" || "strict_hour_minute_second_millis"

A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and three digit fraction of second: HH:mm:ss.SSS.

"ordinal_date" || "strict_ordinal_date"

A formatter for a full ordinal date, using a four digit year and three digit dayOfYear: yyyy-DDD.

"ordinal_date_time" || "strict_ordinal_date_time"

A formatter for a full ordinal date and time, using a four digit year and three digit dayOfYear: yyyy-DDD'T'HH:mm:ss.SSSZZ.

"ordinal_date_time_no_millis" || "strict_ordinal_date_time_no_millis"

A formatter for a full ordinal date and time without millis, using a four digit year and three digit dayOfYear: yyyy-DDD'T'HH:mm:ssZZ.

"time" || "strict_time"

A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, three digit fraction of second, and time zone offset: HH:mm:ss.SSSZZ.

"time_no_millis" || "strict_time_no_millis"

A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and time zone offset: HH:mm:ssZZ.

"t_time" || "strict_t_time"

A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, three digit fraction of second, and time zone offset prefixed by T: 'T'HH:mm:ss.SSSZZ.

"t_time_no_millis" || "strict_t_time_no_millis"

A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and time zone offset prefixed by T: 'T'HH:mm:ssZZ.

"week_date" || "strict_week_date"

A formatter for a full date as four digit weekyear, two digit week of weekyear, and one digit day of week: xxxx-'W'ww-e.

"week_date_time" || "strict_week_date_time"

A formatter that combines a full weekyear date and time, separated by a T: xxxx-'W'ww-e'T'HH:mm:ss.SSSZZ.

"week_date_time_no_millis" || "strict_week_date_time_no_millis"

A formatter that combines a full weekyear date and time without millis, separated by a T: xxxx-'W'ww-e'T'HH:mm:ssZZ.

"weekyear" || "strict_weekyear"

A formatter for a four digit weekyear: xxxx.

"weekyear_week" || "strict_weekyear_week"

A formatter for a four digit weekyear and two digit week of weekyear: xxxx-'W'ww.

"weekyear_week_day" || "strict_weekyear_week_day"

A formatter for a four digit weekyear, two digit week of weekyear, and one digit day of week: xxxx-'W'ww-e.

"year" || "strict_year"

A formatter for a four digit year: yyyy.

"year_month" || "strict_year_month"

A formatter for a four digit year and two digit month of year: yyyy-MM.

"year_month_day" || "strict_year_month_day"

A formatter for a four digit year, two digit month of year, and two digit day of month: yyyy-MM-dd.

https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html

https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html

func (FormatParam) Format

func (f FormatParam) Format() string

Format is the format(s) that the that can be parsed. Defaults to strict_date_optional_time||epoch_millis.

Multiple formats can be seperated by ||

func (*FormatParam) SetFormat

func (f *FormatParam) SetFormat(v string)

type FunctionScore

type FunctionScore struct {
	Query         Query `json:"query,omitempty" bson:"query,omitmepty"`
	BoostParam    `json:",inline" bson:",inline"`
	MaxBoostParam `json:",inline" bson:",inline"`
}

FunctionScore allows you to modify the score of documents that are retrieved by a query. This can be useful if, for example, a score function is computationally expensive and it is sufficient to compute the score on a filtered set of documents.

To use function_score, the user has to define a query and one or more functions, that compute a new score for each document returned by the query.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html

type FuzzinessParam

type FuzzinessParam struct {
	FuzzinessValue    string  `json:"fuzziness,omitempty" bson:"fuzziness,omitempty"`
	FuzzyRewriteValue Rewrite `json:"fuzzy_rewrite,omitempty" bson:"fuzzy_rewrite,omitempty"`
}

FuzzinessParam is a mixin that adds the fuzziness parameter to queries

Maximum edit distance allowed for matching. See Fuzziness for valid values and more information.

https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#fuzziness

func (FuzzinessParam) Fuzziness

func (f FuzzinessParam) Fuzziness() string

Fuzziness is the maximum edit distance allowed for matching. See Fuzziness for valid values and more information.

https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#fuzziness

func (FuzzinessParam) FuzzyRewrite

func (f FuzzinessParam) FuzzyRewrite() Rewrite

FuzzyRewrite is the method used to rewrite the query. See the rewrite parameter for valid values and more information.

If the fuzziness parameter is not 0, the match query uses a fuzzy_rewrite method of top_terms_blended_freqs_${max_expansions} by default.

func (*FuzzinessParam) SetFuzziness

func (f *FuzzinessParam) SetFuzziness(v string)

SetFuzziness sets the fuzzinessValue to v

func (*FuzzinessParam) SetFuzzyRewrite

func (f *FuzzinessParam) SetFuzzyRewrite(v Rewrite) error

SetFuzzyRewrite sets the value of FuzzyRewrite to v

type Fuzzy

type Fuzzy struct {
	Value               string `json:"value" bson:"value"`
	FuzzinessParam      `json:",inline" bson:",inline"`
	MaxExpansionsParam  `json:",inline" bson:",inline"`
	PrefixLengthParam   `json:",inline" bson:",inline"`
	TranspositionsParam `json:",inline" bson:",inline"`
	RewriteParam        `json:",inline" bson:",inline"`
}

Fuzzy returns documents that contain terms similar to the search term, as measured by a Levenshtein edit distance.

An edit distance is the number of one-character changes needed to turn one term into another. These changes can include:

  • Changing a character (box → fox)

  • Removing a character (black → lack)

  • Inserting a character (sic → sick)

  • Transposing two adjacent characters (act → cat)

To find similar terms, the fuzzy query creates a set of all possible variations, or expansions, of the search term within a specified edit distance. The query then returns exact matches for each expansion.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-fuzzy-query.html

func NewFuzzy

func NewFuzzy() Fuzzy

type FuzzyQuery

type FuzzyQuery struct {
	Fuzzy map[string]Fuzzy `json:"fuzzy,omitempty" bson:"fuzzy,omitempty"`
}

FuzzyQuery returns documents that contain terms similar to the search term, as measured by a Levenshtein edit distance.

An edit distance is the number of one-character changes needed to turn one term into another. These changes can include:

  • Changing a character (box → fox)

  • Removing a character (black → lack)

  • Inserting a character (sic → sick)

  • Transposing two adjacent characters (act → cat)

To find similar terms, the fuzzy query creates a set of all possible variations, or expansions, of the search term within a specified edit distance. The query then returns exact matches for each expansion.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-fuzzy-query.html

func NewFuzzyQuery

func NewFuzzyQuery() FuzzyQuery

type FuzzyTranspositionsParam

type FuzzyTranspositionsParam struct {
	FuzzyTranspositionsValue *bool `json:"fuzzy_transpositions,omitempty" bson:"fuzzy_transpositions,omitempty"`
}

func (FuzzyTranspositionsParam) FuzzyTranspositions

func (ft FuzzyTranspositionsParam) FuzzyTranspositions() bool

FuzzyTranspositions edits for fuzzy matching include transpositions of two adjacent characters (ab → ba). Defaults to true

func (*FuzzyTranspositionsParam) SetFuzzyTranspositions

func (ft *FuzzyTranspositionsParam) SetFuzzyTranspositions(v bool)

SetFuzzyTranspositions sets FuzzyTranspositions to v

type IDsQuery

type IDsQuery struct {
	IDs []string `json:"values" bson:"values"`
}

type IndicesBoost

type IndicesBoost map[string]float64

IndicesBoost boosts the _score of documents from specified indices

func (IndicesBoost) Clone

func (ib IndicesBoost) Clone() IndicesBoost

type LenientParam

type LenientParam struct {
	LenientValue *bool `json:"lenient,omitempty" bson:"lenient,omitempty"`
}

LenientParam is a query mixin that adds the lenient para

if true, format-based errors, such as providing a text query value for a numeric field, are ignored. Defaults to false.

func (LenientParam) Lenient

func (l LenientParam) Lenient() bool

Lenient determines whether format-based errors, such as providing a text query value for a numeric field, are ignored. Defaults to false.

func (*LenientParam) SetLenient

func (l *LenientParam) SetLenient(v bool)

SetLenient sets Lenient to v

type Lookup

type Lookup struct {
	// Index (Required, string) Name of the index from which to fetch field
	// values.
	Index string
	// ID (Required, string) ID of the document from which to fetch field
	// values.
	ID string
	// Path (Required, string) Name of the field from which to fetch field
	// values. Elasticsearch uses these values as search terms for the query.
	//
	// If the field values include an array of nested inner objects, you can
	// access those objects using dot notation syntax.
	Path string
	// Routing value of the document from which to fetch term values. If a
	// custom routing value was provided when the document was indexed, this
	// parameter is required. (Optional)
	Routing string

	Boost           float64
	CaseInsensitive bool
}

func (Lookup) Rule

func (l Lookup) Rule() (Rule, error)

func (Lookup) Terms

func (l Lookup) Terms() (*TermsRule, error)

func (Lookup) Type

func (l Lookup) Type() Type

type Match

type Match struct {
	Query                             interface{}
	Analyzer                          string
	NoAutoGenerateSynonymsPhraseQuery bool
	NoFuzzyTranspositions             bool
	Fuzziness                         string
	FuzzyRewrite                      Rewrite
	Lenient                           bool
	Operator                          Operator
	MaxExpansions                     int
	PrefixLength                      int
	MinimumShouldMatchParam           string
	ZeroTermsQuery                    ZeroTermsQuery
}

Match returns documents that match a provided text, number, date or boolean value. The provided text is analyzed before matching.

The match query is the standard query for performing a full-text search, including options for fuzzy matching.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html

func (Match) Match

func (m Match) Match() (*MatchRule, error)

func (Match) Rule

func (m Match) Rule() (Rule, error)

func (Match) Type

func (m Match) Type() Type

type MatchAll

type MatchAll struct {
	Boost float64
}

func (MatchAll) MatchAll

func (ma MatchAll) MatchAll() *MatchAllRule

func (MatchAll) Rule

func (ma MatchAll) Rule() (Rule, error)

func (MatchAll) Type

func (ma MatchAll) Type() Type

type MatchAllQuery

type MatchAllQuery struct {
	MatchAllValue *MatchAll `json:"match_all,omitempty" bson:"match_all,omitempty"`
}

func (*MatchAllQuery) SetMatchAll

func (ma *MatchAllQuery) SetMatchAll(v *MatchAll)

func (MatchAllQuery) Type

func (ma MatchAllQuery) Type() Type

type MatchAllRule

type MatchAllRule struct {
	BoostParam `json:",inline" bson:",inline"`
}

func (MatchAllRule) Type

func (MatchAllRule) Type() Type

type MatchBooleanPrefix

type MatchBooleanPrefix struct {
	Query                    string `json:"query" bson:"query"`
	MinimumShouldMatchParam  `json:",inline" bson:",inline"`
	OperatorParam            `json:",inline" bson:",inline"`
	AnalyzerParam            `json:",inline" bson:",inline"`
	FuzzinessParam           `json:",inline" bson:",inline"`
	PrefixLengthParam        `json:",inline" bson:",inline"`
	FuzzyTranspositionsParam `json:",inline" bson:",inline"`
}

type MatchBooleanPrefixQuery

type MatchBooleanPrefixQuery struct {
	MatchBooleanPrefix map[string]MatchBooleanPrefix `json:"match_boolean_prefix,omitempty" bson:"match_boolean_prefix,omitempty"`
}

func NewMatchBooleanPrefixQuery

func NewMatchBooleanPrefixQuery() MatchBooleanPrefixQuery

type MatchPhrase

type MatchPhrase struct {
	Query               string `json:"query" bson:"query"`
	AnalyzerParam       `json:",inline" bson:",inline"`
	ZeroTermsQueryParam `json:",inline" bson:",inline"`
}

type MatchPhrasePrefix

type MatchPhrasePrefix struct {
	Query              string `json:"query" bson:"query"`
	AnalyzerParam      `json:",inline" bson:",inline"`
	MaxExpansionsParam `json:",inline" bson:",inline"`
	SlopParam          `json:",inline" bson:",inline"`
	ZeroTermsQuery     `json:",inline" bson:",inline"`
}

func NewMatchPhrasePrefix

func NewMatchPhrasePrefix(query string) MatchPhrasePrefix

type MatchPhrasePrefixQuery

type MatchPhrasePrefixQuery struct {
	MatchPhrasePrefix map[string]MatchBooleanPrefix `json:"match_phrase_prefix,omitempty" bson:"match_phrase_prefix,omitempty"`
}

type MatchPhraseQuery

type MatchPhraseQuery struct {
	MatchPhrase map[string]MatchPhrase `json:"match_phrase,omitempty" bson:"match_phrase,omitempty"`
}

func (*MatchPhraseQuery) SetMatchPhrase

func (mp *MatchPhraseQuery) SetMatchPhrase(field string, matchPhrase MatchPhrase)

type MatchQuery

type MatchQuery struct {
	MatchQueryValue map[string]*MatchRule `json:"match,omitempty" bson:"match,omitempty"`
}

MatchQuery returns documents that match a provided text, number, date or boolean value. The provided text is analyzed before matching.

The match query is the standard query for performing a full-text search, including options for fuzzy matching.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html

func (*MatchQuery) Match

func (m *MatchQuery) Match() (key string, value *MatchRule)

func (*MatchQuery) SetMatch

func (m *MatchQuery) SetMatch(field string, match *Match) error

func (MatchQuery) Type

func (m MatchQuery) Type() Type

type MatchRule

type MatchRule struct {
	// (Required) Text, number, boolean value or date you wish to find in the
	// provided <field>.
	//
	// The match query analyzes any provided text before performing a search.
	// This means the match query can search text fields for analyzed tokens
	// rather than an exact term.
	Query dynamic.StringNumberBoolOrTime `json:"query" bson:"query"`

	// Analyzer used to convert the text in the query value into tokens.
	// Defaults to the index-time analyzer mapped for the <field>. If no
	// analyzer is mapped, the index’s default analyzer is used.
	AnalyzerParam `json:",inline" bson:",inline"`

	// If true, match phrase queries are automatically created for multi-term
	// synonyms. Defaults to true.
	AutoGenerateSynonymsPhraseQueryParam `json:",inline" bson:",inline"`

	// Maximum edit distance allowed for matching.
	FuzzinessParam `json:",inline" bson:",inline"`

	// Maximum number of terms to which the query will expand. Defaults to 50.
	MaxExpansionsParam `json:",inline" bson:",inline"`

	// Number of beginning characters left unchanged for fuzzy matching. Defaults to 0.
	PrefixLengthParam `json:",inline" bson:",inline"`

	// If true, edits for fuzzy matching include transpositions of two adjacent
	// characters (ab → ba). Defaults to true.
	FuzzyTranspositionsParam `json:",inline" bson:",inline"`

	//  If true, format-based errors, such as providing a text query value for a
	//  numeric field, are ignored. Defaults to false.
	LenientParam `json:",inline" bson:",inline"`

	// Boolean logic used to interpret text in the query value.
	OperatorParam `json:",inline" bson:",inline"`

	// Minimum number of clauses that must match for a document to be returned
	//
	// https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-minimum-should-match.html
	MinimumShouldMatchParam `json:",inline" bson:",inline"`
	// Indicates whether no documents are returned if the analyzer removes all
	// tokens, such as when using a stop filter.
	ZeroTermsQueryParam `json:",inline" bson:",inline"`
}

MatchRule returns documents that match a provided text, number, date or boolean value. The provided text is analyzed before matching.

The match query is the standard query for performing a full-text search, including options for fuzzy matching.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html

func (*MatchRule) SetQuery

func (mq *MatchRule) SetQuery(value interface{}) error

func (*MatchRule) Type

func (mq *MatchRule) Type() Type

type MaxBoostParam

type MaxBoostParam struct {
	MaxBoostValue *float64 `json:"max_boost,omitempty" bson:"max_boost,omitempty"`
}

func (MaxBoostParam) MaxBoost

func (mb MaxBoostParam) MaxBoost() float64

func (MaxBoostParam) SetMaxBoost

func (mb MaxBoostParam) SetMaxBoost(v float64)

type MaxExpansionsParam

type MaxExpansionsParam struct {
	MaxExpansionsValue *int `json:"max_expansions,omitempty" bson:"max_expansions,omitempty"`
}

MaxExpansionsParam is a mixin that adds the max_expansions param to queries

Maximum number of variations created. Defaults to 50.

WARNING

Avoid using a high value in the max_expansions parameter, especially if the prefix_length parameter value is 0. High values in the max_expansions parameter can cause poor performance due to the high number of variations examined.

func (MaxExpansionsParam) MaxExpansions

func (me MaxExpansionsParam) MaxExpansions() int

MaxExpansions is the maximum number of variations created. Defaults to 50.

func (*MaxExpansionsParam) SetMaxExpansions

func (me *MaxExpansionsParam) SetMaxExpansions(v int)

type MinimumShouldMatchParam

type MinimumShouldMatchParam struct {
	MimimumShouldMatchValue string `json:"minimum_should_match,omitempty" bson:"minimum_should_match,omitempty"`
}

func (MinimumShouldMatchParam) MinimumShouldMatch

func (msm MinimumShouldMatchParam) MinimumShouldMatch() string

func (*MinimumShouldMatchParam) SetMinimumShouldMatch

func (msm *MinimumShouldMatchParam) SetMinimumShouldMatch(v string)

type NameParam

type NameParam struct {
	NameValue string `json:"_name,omitempty" bson:"_name,omitempty"`
}

NameParam is a mixin that adds the _name parameter

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html#named-queries

func (NameParam) Name

func (n NameParam) Name() string

func (*NameParam) SetName

func (n *NameParam) SetName(name string)

type Operator

type Operator string
const (
	// Or Operator
	//
	// For example, a query value of capital of Hungary is interpreted as
	// capital OR of OR Hungary.
	Or Operator = "OR"
	// And Operator
	//
	// For example, a query value of capital of Hungary is interpreted as capital
	// AND of AND Hungary.
	And Operator = "AND"
)

type OperatorParam

type OperatorParam struct {
	OperatorValue *Operator `json:"operator,omitempty" bson:"operator,omitempty"`
}

OperatorParam is a query mixin that adds the operator param

func (OperatorParam) Operator

func (o OperatorParam) Operator() Operator

Operator is the boolean logic used to interpret text in the query value. Defaults to Or

func (*OperatorParam) SetOperator

func (o *OperatorParam) SetOperator(v Operator)

SetOperator sets the Operator to v

type Param

type Param String
const (
	ParamBoost                           Param = "boost"
	ParamAnalyzer                        Param = "analyzer"
	ParamFormat                          Param = "format"
	ParamCaseInsensitive                 Param = "case_insensitive"
	ParamFuzziness                       Param = "fuzziness"
	ParamFuzzyRewrite                    Param = "fuzzy_rewrite"
	ParamFuzzyTranspositions             Param = "fuzzy_transpositions"
	ParamAutoGenerateSynonymsPhraseQuery Param = "auto_generate_synonyms_phrase_query"
	ParamLenient                         Param = "lenient"
	ParamMaxBoost                        Param = "max_boost"
	ParamMaxExpansions                   Param = "max_expansions"
	ParamMinShouldMatch                  Param = "minimum_should_match"
	ParamName                            Param = "_name"
	ParamOperator                        Param = "operator"
	ParamPrefixLength                    Param = "prefix_length"
	ParamRelation                        Param = "relation"
	ParamRewrite                         Param = "rewrite"
	ParamZeroTermsQuery                  Param = "zero_terms_query"
	ParamTranspositions                  Param = "transpositions"
	ParamTimeZone                        Param = "time_zone"
	ParamSlop                            Param = "slop"
)

type Params

type Params []Param

func (Params) Contains

func (p Params) Contains(param string) bool

type PointInTime

type PointInTime struct {
	ID        string     `bson:"id" json:"id"`
	KeepAlive *time.Time `bson:"keep_alive,omitempty" json:"keep_alive,omitempty"`
}

PointInTime is a lightweight view into the state of the data as it existed when initiated.

! X-Pack

A search request by default executes against the most recent visible data of the target indices, which is called point in time. Elasticsearch pit (point in time) is a lightweight view into the state of the data as it existed when initiated. In some cases, it’s preferred to perform multiple search requests using the same point in time. For example, if refreshes happen between search_after requests, then the results of those requests might not be consistent as changes happening between searches are only visible to the more recent point in time.

Prerequisites

  • If the Elasticsearch security features are enabled, you must have the read

index privilege for the target data stream, index, or index alias.

  • To search a point in time (PIT) for an index alias, you must have the read

index privilege for the alias’s concrete indices.

https://www.elastic.co/guide/en/elasticsearch/reference/current/point-in-time-api.html

func (*PointInTime) Clone

func (pit *PointInTime) Clone() *PointInTime

type Prefix

type Prefix struct {
	Value           string
	Rewrite         Rewrite
	CaseInsensitive bool
}

func (Prefix) Query

func (p Prefix) Query() (*PrefixRule, error)

func (Prefix) Rule

func (p Prefix) Rule() (Rule, error)

func (Prefix) Type

func (p Prefix) Type() Type

type PrefixLengthParam

type PrefixLengthParam struct {
	PrefixLengthValue *int `json:"prefix_length,omitempty" bson:"prefix_length,omitempty"`
}

func (PrefixLengthParam) PrefixLength

func (pl PrefixLengthParam) PrefixLength() int

func (*PrefixLengthParam) SetPrefixLength

func (pl *PrefixLengthParam) SetPrefixLength(v int)

type PrefixQuery

type PrefixQuery struct {
	*PrefixRule `json:"prefix,omitempty" bson:"prefix,omitempty"`
}

PrefixQuery returns documents that contain a specific prefix in a provided field.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-prefix-query.html

func (*PrefixQuery) SetPrefix

func (p *PrefixQuery) SetPrefix(v Prefix) error

SetPrefix returns documents that contain a specific prefix in a provided field.

SetPrefix panics if Value is not set. It is intended to be used inside of a builder.

func (PrefixQuery) Type

func (p PrefixQuery) Type() Type

type PrefixRule

type PrefixRule struct {
	Value                string `json:"value" bson:"value"`
	RewriteParam         `json:",inline" bson:",inline"`
	CaseInsensitiveParam `json:",inline" bson:",inline"`
}

PrefixRule returns documents that contain a specific prefix in a provided field.

func (PrefixRule) Type

func (p PrefixRule) Type() Type

type Query

type Query struct {
	MatchQuery   `json:"match" bson:"match"`
	ScriptQuery  `json:"script" bson:"script"`
	ExistsQuery  `json:"exists" bson:"exists"`
	BooleanQuery `json:"bool" bson:"bool"`
	TermQuery    `json:"term" bson:"term"`
	TermsQuery   `json:"terms" bson:"terms"`
}

Query defines the search definition using the ElasticSearch Query DSL

Elasticsearch provides a full Query DSL (Domain Specific Language) based on JSON to define queries. Think of the Query DSL as an AST (Abstract Syntax Tree) of queries, consisting of two types of clauses:

Leaf query clauses

Leaf query clauses look for a particular value in a particular field, such as the match, term or range queries. These queries can be used by themselves.

Compound query clauses

Compound query clauses wrap other leaf or compound queries and are used to combine multiple queries in a logical fashion (such as the bool or dis_max query), or to alter their behaviour (such as the constant_score query).

Query clauses behave differently depending on whether they are used in query context or filter context.

func (*Query) Clone

func (q *Query) Clone() *Query

type QueryError

type QueryError struct {
	Field string
	Err   error
	Type  Type
}

func NewQueryError

func NewQueryError(err error, queryType Type, field ...string) *QueryError

func (QueryError) Error

func (s QueryError) Error() string

func (QueryError) Unwrap

func (s QueryError) Unwrap() error

type QueryParam

type QueryParam struct {
	QueryValue *Query `json:"query,omitempty" bson:"query,omitempty"`
}

type Range

type Range struct {
	Field                string
	GreaterThan          interface{}
	GreaterThanOrEqualTo interface{}
	LessThan             interface{}
	LessThanOrEqualTo    interface{}
	Format               string
	TimeZone             string
	Boost                float64
}

Range returns documents that contain terms within a provided range.

func (Range) Range

func (r Range) Range() (*RangeRule, error)

func (Range) Rule

func (r Range) Rule() (Rule, error)

func (Range) Type

func (r Range) Type() Type

type RangeQuery

type RangeQuery struct {
	RangeValue map[string]*RangeRule `json:"range,omitempty" bson:"range,omitempty"`
}

func (*RangeQuery) AddRange

func (r *RangeQuery) AddRange(field string, value Range) error

func (*RangeQuery) AssignRange

func (r *RangeQuery) AssignRange(field string, value Range) error

func (*RangeQuery) RemoveRange

func (r *RangeQuery) RemoveRange(field string)

func (*RangeQuery) SetRange

func (r *RangeQuery) SetRange(ranges map[string]Range) error

type RangeRule

type RangeRule struct {
	GreaterThanValue          *dynamic.StringNumberOrTime `json:"gt,omitempty" bson:"gt,omitempty"`
	GreaterThanOrEqualToValue *dynamic.StringNumberOrTime `json:"gte,omitempty" bson:"gt,omitempty"`
	LessThanValue             *dynamic.StringNumberOrTime `json:"lt,omitempty" bson:"lt,omitempty"`
	LessThanOrEqualToValue    *dynamic.StringNumberOrTime `json:"lte,omitempty" bson:"lte,omitempty"`
	FormatParam               `json:",inline" bson:",inline"`
	TimeZoneParam             `json:",inline" bson:",inline"`
	BoostParam                `json:",inline" bson:",inline"`
}

func (*RangeRule) GreaterThan

func (r *RangeRule) GreaterThan() *dynamic.StringNumberOrTime

func (*RangeRule) GreaterThanOrEqualTo

func (r *RangeRule) GreaterThanOrEqualTo() *dynamic.StringNumberOrTime

func (*RangeRule) LessThan

func (r *RangeRule) LessThan() *dynamic.StringNumberOrTime

func (*RangeRule) LessThanOrEqualTo

func (r *RangeRule) LessThanOrEqualTo() *dynamic.StringNumberOrTime

func (*RangeRule) SetGreaterThan

func (r *RangeRule) SetGreaterThan(value interface{}) error

func (*RangeRule) SetGreaterThanOrEqualTo

func (r *RangeRule) SetGreaterThanOrEqualTo(value interface{}) error

func (*RangeRule) SetLessThan

func (r *RangeRule) SetLessThan(value interface{}) error

func (*RangeRule) SetLessThanOrEqualTo

func (r *RangeRule) SetLessThanOrEqualTo(value interface{}) error

func (RangeRule) Type

func (r RangeRule) Type() Type

type Relation

type Relation string
const (
	//RelationIntersects matches documents with a range field value that
	//intersects the query’s range.
	RelationIntersects Relation = "INTERSECTS"
	// RelationContains matches documents with a range field value that entirely
	// contains the query’s range.
	RelationContains Relation = "CONTAINS"
	// RelationWithin matches documents with a range field value entirely within
	// the query’s range.
	RelationWithin Relation = "WITHIN"
)

type RelationParam

type RelationParam struct {
	RelationValue Relation `json:"relation,omitempty" bson:"relation,omitempty"`
}

RelationParam is a mixin that adds the relation parameter

func (RelationParam) Relation

func (r RelationParam) Relation() Relation

Relation indicates how the range query matches values for range fields.

func (*RelationParam) SetRelation

func (r *RelationParam) SetRelation(v Relation)

SetRelation sets Relation to v

type Rewrite

type Rewrite string

Rewrite as defined by:

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-term-rewrite.html

const (
	// RewriteTypeConstantScore uses the constant_score_boolean method for fewer matching
	// terms. Otherwise, this method finds all matching terms in sequence and
	// returns matching documents using a bit set.
	RewriteConstantScore Rewrite = "constant_score"

	// RewriteTypeConstantScoreBoolean assigns each document a relevance score equal to the
	// boost parameter.
	//
	// This method changes the original query to a bool query. This bool query
	// contains a should clause and term query for each matching term.
	//
	// This method can cause the final bool query to exceed the clause limit in the
	// indices.query.bool.max_clause_count setting. If the query exceeds this limit,
	// Elasticsearch returns an error.
	RewriteConstantScoreBoolean Rewrite = "constant_score_boolean"

	// RewriteTypeScoringBoolean calculates a relevance score for each matching document.
	//
	// This method changes the original query to a bool query. This bool query
	// contains a should clause and term query for each matching term.
	//
	// This method can cause the final bool query to exceed the clause limit in the
	// indices.query.bool.max_clause_count setting. If the query exceeds this limit,
	// Elasticsearch returns an error.
	RewriteScoringBoolean Rewrite = "scoring_boolean"

	// RewriteTypeTopTermsBlendedFreqsN calculates a relevance score for each
	// matching document as if all terms had the same frequency. This frequency
	// is the maximum frequency of all matching terms.
	//
	// This method changes the original query to a bool query. This bool query
	// contains a should clause and term query for each matching term.
	//
	// The final bool query only includes term queries for the top N scoring
	// terms.
	//
	// You can use this method to avoid exceeding the clause limit in the
	// indices.query.bool.max_clause_count setting.
	//
	RewriteTopTermsBlendedFreqsN Rewrite = "top_terms_blended_freqs_N"

	// RewriteTypeTopTermsBoostN Assigns each matching document a relevance
	// score equal to the boost parameter.
	//
	// This method changes the original query to a bool query. This bool query
	// contains a should clause and term query for each matching term.
	//
	// The final bool query only includes term queries for the top N terms.
	//
	// You can use this method to avoid exceeding the clause limit in the
	// indices.query.bool.max_clause_count setting.
	RewriteTopTermsBoostN Rewrite = "top_terms_boost_N"

	// RewriteTopTermsN calculates a relevance score for each matching document.
	//
	// This method changes the original query to a bool query. This bool query
	// contains a should clause and term query for each matching term.
	//
	// The final bool query only includes term queries for the top N scoring terms.
	//
	// You can use this method to avoid exceeding the clause limit in the
	// indices.query.bool.max_clause_count setting.
	RewriteTopTermsN Rewrite = "top_terms_N"
)

func (Rewrite) IsValid

func (r Rewrite) IsValid() bool

type RewriteParam

type RewriteParam struct {
	RewriteValue *Rewrite `json:"rewrite,omitempty" bson:"rewrite,omitempty"`
}

RewriteParam is a mixin that adds the rewrite param

Method used to rewrite the query. For valid values and more information, see the rewrite parameter. (Optional)

func (RewriteParam) Default

func (r RewriteParam) Default() Rewrite

func (RewriteParam) Rewrite

func (r RewriteParam) Rewrite() Rewrite

func (*RewriteParam) SetRewrite

func (r *RewriteParam) SetRewrite(v Rewrite)

type Rule

type Rule interface {
	Type() Type
}

type RuleError

type RuleError struct {
	*QueryError
	Rule Rule
}

func NewRuleError

func NewRuleError(err error, queryType Type, rule Rule, field ...string) *RuleError

type Ruler

type Ruler interface {
	Rule() (Rule, error)
}

type Rules

type Rules []Clause

func (*Rules) Add

func (r *Rules) Add(typ Type, rule Rule) error

type RuntimeMappingField

type RuntimeMappingField struct {
	Type   RuntimeMappingType `bson:"type" json:"type"`
	Script string             `bson:"script,omitempty" json:"script,omitempty"`
}

type RuntimeMappingType

type RuntimeMappingType string
const (
	RMTBoolean  RuntimeMappingType = "boolean"
	RMTDate     RuntimeMappingType = "date"
	RMTDouble   RuntimeMappingType = "double"
	RMTGeoPoint RuntimeMappingType = "geo_point"
	RMTIP       RuntimeMappingType = "ip"
	RMTKeyword  RuntimeMappingType = "keyword"
	RMTLong     RuntimeMappingType = "long"
)

type RuntimeMappings

type RuntimeMappings map[string]RuntimeMappingField

func (RuntimeMappings) Clone

func (rtm RuntimeMappings) Clone() RuntimeMappings

type Script

type Script struct {
	Source   string                 `json:"source" bson:"source"`
	Language string                 `json:"lang,omitempty" bson:"lang,omitempty"`
	Params   map[string]interface{} `json:"params,omitempty" bson:"params,omitempty"`
}

Script filters documents based on a provided script. The script query is typically used in a filter context.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-script-query.html

func (Script) MarshalJSON

func (s Script) MarshalJSON() ([]byte, error)

func (*Script) UnmarshalJSON

func (s *Script) UnmarshalJSON(data []byte) error

type ScriptQuery

type ScriptQuery struct {
	ScriptValue *Script `json:"script,omitempty" bson:"script,omitempty"`
}

ScriptQuery filters documents based on a provided script. The script query is typically used in a filter context.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-script-query.html

func (*ScriptQuery) RemoveScriptParam

func (s *ScriptQuery) RemoveScriptParam(key string)

func (ScriptQuery) ScriptLanguage

func (s ScriptQuery) ScriptLanguage() string

func (ScriptQuery) ScriptParams

func (s ScriptQuery) ScriptParams() map[string]interface{}

func (ScriptQuery) ScriptSource

func (s ScriptQuery) ScriptSource() string

func (*ScriptQuery) SetScriptLanguage

func (s *ScriptQuery) SetScriptLanguage(v string)

func (*ScriptQuery) SetScriptParam

func (s *ScriptQuery) SetScriptParam(key string, value interface{})

func (*ScriptQuery) SetScriptParams

func (s *ScriptQuery) SetScriptParams(v map[string]interface{})

func (*ScriptQuery) SetScriptSource

func (s *ScriptQuery) SetScriptSource(v string)
type Search struct {
	// Defines the search definition using the Query DSL. (Optional)
	QueryParam `bson:",inline" json:",inline"`
	// Array of wildcard (*) patterns. The request returns doc values for field
	// names matching these patterns in the hits.fields property of the response
	// (Optional) .
	//
	// You can specify items in the array as a string or object.
	DocValueFieldsValue DocValueFields `bson:"docvalue_fields,omitempty" json:"docvalue_fields,omitempty"`

	// Array of wildcard (*) patterns. The request returns values for field
	// names matching these patterns in the hits.fields property of the response
	// (Optional).
	//
	// You can specify items in the array as a string or object.
	FieldsValue Fields `bson:"fields,omitempty" json:"fields,omitempty"`

	// (Optional, Boolean) If true, returns detailed information about score
	// computation as part of a hit. Defaults to false.
	ExplainValue *bool `bson:"epxlain,omitempty" json:"explain,omitempty"`

	// Starting document offset. Defaults to 0.
	//
	// By default, you cannot page through more than 10,000 hits using the from
	// and size parameters. To page through more hits, use the search_after
	// parameter.
	FromValue *int `bson:"from,omitempty" json:"from,omitempty"`

	// Boosts the _score of documents from specified indices (Optional).
	IndicesBoostValue IndicesBoost `bson:"indices_boost,omitempty"`

	// Minimum _score for matching documents. Documents with a lower _score are
	// not included in the search results (Optional, float).
	MinScoreValue *float64 `bson:"min_score,omitempty" json:"min_score,omitempty"`

	// Limits the search to a point in time (PIT). If you provide a pit, you
	// cannot specify a <target> in the request path. (Optional)
	PointInTimeValue *PointInTime `bson:"pit,omitempty" json:"pit,omitempty"`

	//  Defines a runtime field in the search request that exist only as part of
	//  the query. Fields defined in the search request take precedence over
	//  fields defined with the same name in the index mappings. (Optional)
	RuntimeMappingsValue RuntimeMappings `bson:"runtime_mappings,omitempty" json:"runtime_mappings,omitempty"`

	// If true, returns sequence number and primary term of the last
	// modification of each hit. See Optimistic concurrency control. (Optional)
	SeqNoPrimaryTermValue *bool `bson:"seq_no_primary_term,omitempty" json:"seq_no_primary_term,omitempty"`
	// The number of hits to return. Defaults to 10. (Optional)
	//
	// By default, you cannot page through more than 10,000 hits using the from and size parameters. To page through more hits, use the search_after parameter.
	SizeValue *int `bson:"size,omitempty" json:"size,omitempty"`

	// Indicates which source fields are returned for matching documents. These fields are returned in the hits._source property of the search response. Defaults to true. (Optional)
	SourceValue *Source `bson:"_source,omitempty" json:"_source,omitempty"`

	// Stats groups to associate with the search. Each group maintains a statistics aggregation for its associated searches. You can retrieve these stats using the indices stats API (Optional).
	StatsValue []string `bson:"stats,omitempty" json:"stats,omitempty"`

	TerminateAfterValue *int `bson:"terminate_after,omitempty" json:"terminate_after,omitempty"`

	TimeoutValue *time.Duration `bson:"timeout,omitempty" json:"timeout,omitempty"`

	VersionValue *bool `bson:"version,omitempty" json:"version,omitempty"`
}

func Build

func Build(fn func(s *Search) (*Search, error)) (*Search, error)

func NewSearch

func NewSearch() *Search

func (*Search) Clone

func (s *Search) Clone() *Search

func (Search) DocValueFields

func (s Search) DocValueFields() DocValueFields

DocValueFields is used to return return doc values for one or more fields in the search response.

(Optional, array of strings and objects) Array of wildcard (*) patterns. The request returns doc values for field names matching these patterns in the hits.fields property of the response.

You can specify items in the array as a string or object.

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-fields.html#docvalue-fields

func (Search) Explain

func (s Search) Explain() bool

Explain indicates whether the search returns detailed information about score computation as part of a hit. Defaults to false.

func (Search) Fields

func (s Search) Fields() Fields

Fields allows for retrieving a list of document fields in the search response. It consults both the document _source and the index mappings to return each value in a standardized way that matches its mapping type. By default, date fields are formatted according to the date format parameter in their mappings. You can also use the fields parameter to retrieve runtime field values.

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-fields.html#search-fields-param

func (Search) From

func (s Search) From() int

From sets the starting document offset. Defaults to 0.

By default, you cannot page through more than 10,000 hits using the from and size parameters. To page through more hits, use the search_after parameter.

func (Search) IndicesBoost

func (s Search) IndicesBoost() IndicesBoost

IndicesBoost buusts the _score of documents from specified indices

func (Search) MinScore

func (s Search) MinScore() float64

MinScore is the minimum _score for matching documents. Documents with a lower _score are not included in the search results.

func (Search) PIT

func (s Search) PIT() *PointInTime

PIT is an alias for PointInTime

func (Search) PITID

func (s Search) PITID() string

func (Search) PITKeepAlive

func (s Search) PITKeepAlive() *time.Time

func (Search) PointInTime

func (s Search) PointInTime() *PointInTime

PointInTime is a lightweight view into the state of the data as it existed when initiated

https://www.elastic.co/guide/en/elasticsearch/reference/current/point-in-time-api.html

func (Search) PointInTimeID

func (s Search) PointInTimeID() string

func (Search) PointInTimeKeepAlive

func (s Search) PointInTimeKeepAlive() *time.Time

func (Search) Query

func (s Search) Query() *Query

Query defines the search definition using the Query DSL.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html

func (Search) RuntimeMappings

func (s Search) RuntimeMappings() RuntimeMappings

func (*Search) SetDocValueFields

func (s *Search) SetDocValueFields(v DocValueFields) *Search

SetDocValueFields sets DocValueFieldsValue to v

func (*Search) SetExplain

func (s *Search) SetExplain(v bool) *Search

SetExplain sets the ExplainValue to v

func (*Search) SetFields

func (s *Search) SetFields(v Fields) *Search

SetFields sets the FieldsValue to v

func (*Search) SetFrom

func (s *Search) SetFrom(v int) *Search

SetFrom sets the FromValue to v

func (*Search) SetIndicesBoost

func (s *Search) SetIndicesBoost(v IndicesBoost) *Search

SetIndicesBoost sets IndicesBoostValue to v

func (*Search) SetMinScore

func (s *Search) SetMinScore(v float64) *Search

SetMinScore sets the MinScoreValue to v

func (*Search) SetPIT

func (s *Search) SetPIT(v *PointInTime) *Search

SetPIT is an alias for SetPointInTime

func (*Search) SetPointInTime

func (s *Search) SetPointInTime(v *PointInTime) *Search

SetPointInTime sets the PointInTimeValue to v

func (*Search) SetQuery

func (s *Search) SetQuery(v *Query) *Search

SetQuery sets QueryValue to v

func (*Search) SetRuntimeMappings

func (s *Search) SetRuntimeMappings(v RuntimeMappings) *Search

func (*Search) SetSeqNoPrimaryTerm

func (s *Search) SetSeqNoPrimaryTerm(v bool) *Search

func (*Search) SetSize

func (s *Search) SetSize(v int) *Search

func (*Search) SetSource

func (s *Search) SetSource(v interface{}) *Search

SetSource sets the value of Source

The options are:

search.Source
*search.Source
string
[]string
dynamic.StringOrArrayOfStrings
*dynamic.StringOrArrayOfStrings
search.SourceSpecifications
*search.SourceSpecifications
bool
*bool
nil

Note, "true" || "false" get parsed as boolean

SetSource panics if v is not one of the types listed above. The expectation is that this method will be utilized in a Builder

You can explicitly set the source, such as:

s := NewSearch()
src := &Source{}
err := src.SetValue(v)
_ = err // handle err
s.SourceValue = src

func (*Search) SetStats

func (s *Search) SetStats(v []string) *Search

func (*Search) SetTerminateAfter

func (s *Search) SetTerminateAfter(v int) *Search

func (*Search) SetTimeout

func (s *Search) SetTimeout(v time.Duration) *Search

func (*Search) SetVersion

func (s *Search) SetVersion(v bool) *Search

func (Search) Size

func (s Search) Size() int

Size is number of hits to return. Defaults to 10.

By default, you cannot page through more than 10,000 hits using the from and size parameters. To page through more hits, use the search_after parameter.

func (Search) Source

func (s Search) Source() *Source

Source indicates which source fields are returned for matching documents. These fields are returned in the hits._source property of the search response. Defaults to true.

func (Search) Stats

func (s Search) Stats() []string

Stats groups to associate with the search. Each group maintains a statistics aggregation for its associated searches. You can retrieve these stats using the indices stats API (Optional).

func (Search) TerminateAfter

func (s Search) TerminateAfter() int

TerminateAfter is maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.

Defaults to 0, which does not terminate query execution early.

func (Search) Timeout

func (s Search) Timeout() time.Duration

Timeout specifies the period of time to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Defaults to no timeout.

func (Search) Version

func (s Search) Version() bool

Version determines whether the document version should be returned as part a hit. Default: false

type SlopParam

type SlopParam struct {
	SlopValue *int `json:"slop,omitempty" bson:"slop,omitempty"`
}

func (*SlopParam) SetSlop

func (s *SlopParam) SetSlop(v int)

func (SlopParam) Slop

func (s SlopParam) Slop() int

type Source

type Source struct {
	BoolValue       *bool                          `bson:"bool,omitempty" json:"-"`
	WildcardPattern dynamic.StringOrArrayOfStrings `bson:"wildcard,omitempty" json:"-"`
	Specifications  *SourceSpecifications
}

func (*Source) SetValue

func (s *Source) SetValue(v interface{}) error

SetValue sets the value of Source

The options are:

string
[]string
dynamic.StringOrArrayOfStrings
*dynamic.StringOrArrayOfStrings
SourceSpecifications
*SourceSpecifications
bool
*bool
nil

SetValue returns an error if v is not one of the types listed above.

func (Source) Value

func (s Source) Value() interface{}

Value indicates which source fields are returned for matching documents. These fields are returned in the hits._source property of the search response. Defaults to true.

type SourceSpecifications

type SourceSpecifications struct {
	Includes dynamic.StringOrArrayOfStrings `bson:"includes,omitempty" json:"includes,omitempty"`
	Excludes dynamic.StringOrArrayOfStrings `bson:"excludes,omitempty" json:"excludes,omitempty"`
}

type String

type String string

func (String) String

func (s String) String() string

func (String) Terms

func (s String) Terms() (*TermsRule, error)

type Strings

type Strings []string

func (Strings) Terms

func (s Strings) Terms() (*TermsRule, error)

type Term

type Term struct {
	Value           string
	Boost           float64
	CaseInsensitive bool
}

func (Term) Rule

func (t Term) Rule() (Rule, error)

func (Term) Term

func (t Term) Term() (*TermRule, error)

func (Term) Type

func (t Term) Type() Type

type TermQuery

type TermQuery struct {
	TermField string
	TermRule  *TermRule
}

TermQuery returns documents that contain an exact term in a provided field.

You can use the term query to find documents based on a precise value such as a price, a product ID, or a username.

Avoid using the term query for text fields.

By default, Elasticsearch changes the values of text fields as part of analysis. This can make finding exact matches for text field values difficult.

To search text field values, use the match query instead.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html

func (TermQuery) MarshalJSON

func (t TermQuery) MarshalJSON() ([]byte, error)

func (*TermQuery) RemoveTerm

func (t *TermQuery) RemoveTerm()

func (*TermQuery) SetTerm

func (t *TermQuery) SetTerm(field string, term *Term) error

func (*TermQuery) UnmarshalJSON

func (t *TermQuery) UnmarshalJSON(data []byte) error

type TermRule

type TermRule struct {
	TermValue            string `json:"value" bson:"value"`
	BoostParam           `json:",inline" bson:",inline"`
	CaseInsensitiveParam `json:",inline" bson:",inline"`
}

TermRule query returns documents that contain an exact term in a provided field.

You can use the term query to find documents based on a precise value such as a price, a product ID, or a username.

Avoid using the term query for text fields.

By default, Elasticsearch changes the values of text fields as part of analysis. This can make finding exact matches for text field values difficult.

To search text field values, use the match query instead.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html

func (*TermRule) SetValue

func (t *TermRule) SetValue(v string)

func (*TermRule) Type

func (t *TermRule) Type() Type

func (*TermRule) UnmarshalJSON

func (t *TermRule) UnmarshalJSON(data []byte) error

func (TermRule) Value

func (t TermRule) Value() string

type Terms

type Terms struct {
	Values          []string
	Boost           float64
	CaseInsensitive bool
}

Terms returns documents that contain one or more exact terms in a provided field.

The terms query is the same as the term query, except you can search for multiple values.

func (Terms) Rule

func (t Terms) Rule() (Rule, error)

func (Terms) Terms

func (t Terms) Terms() (*TermsRule, error)

func (Terms) Type

func (t Terms) Type() Type

type TermsLookup

type TermsLookup struct {
	TermsID      string `json:"id,omitempty" bson:"id,omitempty"`
	TermsIndex   string `json:"index,omitempty" bson:"index,omitempty"`
	TermsPath    string `json:"path,omitempty" bson:"path,omitempty"`
	TermsRouting string `json:"routing,omitempty" bson:"routing,omitempty"`
}

type TermsQuery

type TermsQuery struct {
	Terms TermsRule `json:",inline" bson:",inline"`
}

func (TermsQuery) SetTerms

func (t TermsQuery) SetTerms(field string, value Termser) error

func (*TermsQuery) UnmarshalJSON

func (t *TermsQuery) UnmarshalJSON(data []byte) error

type TermsRule

type TermsRule struct {
	TermsLookup          `json:"-" bson:"-"`
	TermsValue           []string `json:"-" bson:"-"`
	TermsField           string   `json:"-" bson:"-"`
	BoostParam           `json:",inline" bson:",inline"`
	CaseInsensitiveParam `json:",inline" bson:",inline"`
}

func (TermsRule) MarshalBSON

func (t TermsRule) MarshalBSON() ([]byte, error)

func (TermsRule) MarshalJSON

func (t TermsRule) MarshalJSON() ([]byte, error)

func (*TermsRule) SetField

func (t *TermsRule) SetField(field string)

func (*TermsRule) SetLookup

func (t *TermsRule) SetLookup(lookup *TermsLookup)

func (*TermsRule) SetValue

func (t *TermsRule) SetValue(value []string)

func (*TermsRule) Type

func (t *TermsRule) Type() Type

func (*TermsRule) UnmarshalBSON

func (t *TermsRule) UnmarshalBSON(data []byte) error

func (*TermsRule) UnmarshalJSON

func (t *TermsRule) UnmarshalJSON(data []byte) error

func (TermsRule) Value

func (t TermsRule) Value() []string

type Termser

type Termser interface {
	Terms() (*TermsRule, error)
}

Termser can be:

*search.Terms
*search.Lookup
search.String
search.Strings

Example:

impor
s := search.NewSearch()
err := s.AddTerms(&Lookup{ID: "1", Index:"my-index-100", Path:"color"})
_ = err // handle err
err = s.AddTerms(&Terms{ Field:"", Value: []string{"kimchy", "elkbee"}})
_ = err // handle err

type TimeZoneParam

type TimeZoneParam struct {
	TimeZoneValue string `json:"time_zone,omitempty" bson:"time_zone,omitempty"`
}

TimeZoneParam is a mixin that adds the time_zone param to queries

Coordinated Universal Time (UTC) offset or IANA time zone used to convert date values in the query to UTC. Valid values are ISO 8601 UTC offsets, such as +01:00 or -08:00, and IANA time zone IDs, such as America/Los_Angeles.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html#range-query-time-zone

func (*TimeZoneParam) SetTimeZone

func (tz *TimeZoneParam) SetTimeZone(v string)

func (TimeZoneParam) TimeZone

func (tz TimeZoneParam) TimeZone() string

type TranspositionsParam

type TranspositionsParam struct {
	TranspositionsValue *bool `json:"transpositions,omitempty" bson:"transpositions,omitempty"`
}

func (*TranspositionsParam) SetTranspositions

func (t *TranspositionsParam) SetTranspositions(v bool)

SetTranspositions sets the value of Transpositions to v

func (TranspositionsParam) Transpositions

func (t TranspositionsParam) Transpositions() bool

Transpositions indicates whether edits include transpositions of two adjacent characters (ab → ba). Defaults to true.

type Type

type Type string
const (
	TypePrefix         Type = "prefix"
	TypeMatch          Type = "match"
	TypeMatchAll       Type = "match_all"
	TypeTerm           Type = "term"
	TypeTerms          Type = "terms"
	TypeRange          Type = "range"
	TypeBoosting       Type = "boosting"
	TypeBoolean        Type = "boolean"
	TypeConstantScore  Type = "constant_score"
	TypeFunctionScore  Type = "function_score"
	TypeDisjunctionMax Type = "dis_max"
	TypeAllOf          Type = "all_of"
)

func (Type) String

func (qt Type) String() string

type WithAnalyzer

type WithAnalyzer interface {
	// Analyzer used to convert the text in the query value into tokens.
	// Defaults to the index-time analyzer mapped for the <field>. If no
	// analyzer is mapped, the index’s default analyzer is used. (Optional)
	Analyzer() string
	// SetAnalyzer sets the Analyzer value to v
	SetAnalyzer(v string)
}

WithAnalyzer is a query with the analyzer param

https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis.html

type WithAutoGenerateSynonymsPhraseQuery

type WithAutoGenerateSynonymsPhraseQuery interface {
	// AutoGenerateSynonymsPhraseQuery determines if match phrase queries are
	// automatically created for multi-term synonyms. Defaults to true.
	AutoGenerateSynonymsPhraseQuery() bool
	// SetAutoGenerateSynonymsPhraseQuery sets AutoGenerateSynonymsPhraseQueryValue to v
	SetAutoGenerateSynonymsPhraseQuery(v bool)
}

WithAutoGenerateSynonymsPhraseQuery is an interface for the query mixin that adds auto_generate_synonyms_phrase_query param

type WithBoost

type WithBoost interface {
	Boost() float64
	SetBoost(v float64)
}

type WithCaseInsensitive

type WithCaseInsensitive interface {
	CaseInsensitive() bool
	SetCaseInsensitive(v bool)
}

WithCaseInsensitive is a query mixin that adds the case_insensitive param

(Optional, Boolean) Allows ASCII case insensitive matching of the value with the indexed field values when set to true. Default is false which means the case sensitivity of matching depends on the underlying field’s mapping.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html

type WithFormat

type WithFormat interface {
	//The date format(s) that can be parsed. Defaults to
	//strict_date_optional_time||epoch_millis.
	Format() string
	// SetFormat sets the Format Value to v
	SetFormat(v string)
}

WithFormat is a query with a format parameter

In JSON documents, dates are represented as strings. Elasticsearch uses a set of preconfigured formats to recognize and parse these strings into a long value representing milliseconds-since-the-epoch in UTC.

Besides the built-in formats, custom formats can be specified using the familiar yyyy/MM/dd syntax

"epoch_millis"

A formatter for the number of milliseconds since the epoch. Note, that this timestamp is subject to the limits of a Java Long.MIN_VALUE and Long.MAX_VALUE.

"epoch_second"

A formatter for the number of seconds since the epoch. Note, that this timestamp is subject to the limits of a Java Long.MIN_VALUE and Long. MAX_VALUE divided by 1000 (the number of milliseconds in a second).

"date_optional_time" || "strict_date_optional_time"

A generic ISO datetime parser, where the date must include the year at a minimum, and the time (separated by T), is optional. Examples: "yyyy-MM-dd'T'HH:mm:ss.SSSZ" || "yyyy-MM-dd"

"strict_date_optional_time_nanos"

A generic ISO datetime parser, where the date must include the year at a minimum, and the time (separated by T), is optional. The fraction of a second part has a nanosecond resolution. Examples: yyyy-MM-dd'T'HH:mm:ss.SSSSSSZ or yyyy-MM-dd.

"basic_date"

A basic formatter for a full date as four digit year, two digit month of year, and two digit day of month: yyyyMMdd.

"basic_date_time"

A basic formatter that combines a basic date and time, separated by a T: yyyyMMdd'T'HHmmss.SSSZ.

"basic_date_time_no_millis"

A basic formatter that combines a basic date and time without millis, separated by a T: yyyyMMdd'T'HHmmssZ.

"basic_ordinal_date"

A formatter for a full ordinal date, using a four digit year and three digit dayOfYear: yyyyDDD.

"basic_ordinal_date_time"

A formatter for a full ordinal date and time, using a four digit year and three digit dayOfYear: yyyyDDD'T'HHmmss.SSSZ.

"basic_ordinal_date_time_no_millis"

A formatter for a full ordinal date and time without millis, using a four digit year and three digit dayOfYear: yyyyDDD'T'HHmmssZ.

"basic_time"

A basic formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, three digit millis, and time zone offset: HHmmss.SSSZ.

"basic_time_no_millis"

A basic formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and time zone offset: HHmmssZ.

"basic_t_time"

A basic formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, three digit millis, and time zone off set prefixed by T: 'T'HHmmss.SSSZ.

"basic_t_time_no_millis"

A basic formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and time zone offset prefixed by T: 'T'HHmmssZ.

"basic_week_date" || "strict_basic_week_date"

A basic formatter for a full date as four digit weekyear, two digit week of weekyear, and one digit day of week: xxxx'W'wwe.

"basic_week_date_time" || "strict_basic_week_date_time"

A basic formatter that combines a basic weekyear date and time, separated by a T: xxxx'W'wwe'T'HHmmss.SSSZ.

"basic_week_date_time_no_millis" || "strict_basic_week_date_time_no_millis"

A basic formatter that combines a basic weekyear date and time without millis, separated by a T: xxxx'W'wwe'T'HHmmssZ.

"date" || "strict_date"

A formatter for a full date as four digit year, two digit month of year, and two digit day of month: yyyy-MM-dd.

"date_hour" || "strict_date_hour"

A formatter that combines a full date and two digit hour of day: yyyy-MM-dd'T'HH.

"date_hour_minute" || "strict_date_hour_minute"

A formatter that combines a full date, two digit hour of day, and two digit minute of hour: yyyy-MM-dd'T'HH:mm.

"date_hour_minute_second" || "strict_date_hour_minute_second"

A formatter that combines a full date, two digit hour of day, two digit minute of hour, and two digit second of minute: yyyy-MM-dd'T'HH:mm:ss.

"date_hour_minute_second_fraction" || "strict_date_hour_minute_second_fraction"

A formatter that combines a full date, two digit hour of day, two digit minute of hour, two digit second of minute, and three digit fraction of second: yyyy-MM-dd'T'HH:mm:ss.SSS.

"date_hour_minute_second_millis" || "strict_date_hour_minute_second_millis" A formatter that combines a full date, two digit hour of day, two digit minute of hour, two digit second of minute, and three digit fraction of second: yyyy-MM-dd'T'HH:mm:ss.SSS.

"date_time" || "strict_date_time"

A formatter that combines a full date and time, separated by a T: yyyy-MM-dd'T'HH:mm:ss.SSSZZ.

"date_time_no_millis" || "strict_date_time_no_millis" A formatter that combines a full date and time without millis, separated by a T: yyyy-MM-dd'T'HH:mm:ssZZ.

"hour" || "strict_hour" A formatter for a two digit hour of day: HH

"hour_minute" || "strict_hour_minute"

A formatter for a two digit hour of day and two digit minute of hour: HH:mm.

"hour_minute_second" || "strict_hour_minute_second"

A formatter for a two digit hour of day, two digit minute of hour, and two digit second of minute: HH:mm:ss.

"hour_minute_second_fraction" || "strict_hour_minute_second_fraction"

A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and three digit fraction of second: HH:mm:ss.SSS.

"hour_minute_second_millis" || "strict_hour_minute_second_millis"

A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and three digit fraction of second: HH:mm:ss.SSS.

"ordinal_date" || "strict_ordinal_date"

A formatter for a full ordinal date, using a four digit year and three digit dayOfYear: yyyy-DDD.

"ordinal_date_time" || "strict_ordinal_date_time"

A formatter for a full ordinal date and time, using a four digit year and three digit dayOfYear: yyyy-DDD'T'HH:mm:ss.SSSZZ.

"ordinal_date_time_no_millis" || "strict_ordinal_date_time_no_millis"

A formatter for a full ordinal date and time without millis, using a four digit year and three digit dayOfYear: yyyy-DDD'T'HH:mm:ssZZ.

"time" || "strict_time"

A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, three digit fraction of second, and time zone offset: HH:mm:ss.SSSZZ.

"time_no_millis" || "strict_time_no_millis"

A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and time zone offset: HH:mm:ssZZ.

"t_time" || "strict_t_time"

A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, three digit fraction of second, and time zone offset prefixed by T: 'T'HH:mm:ss.SSSZZ.

"t_time_no_millis" || "strict_t_time_no_millis"

A formatter for a two digit hour of day, two digit minute of hour, two digit second of minute, and time zone offset prefixed by T: 'T'HH:mm:ssZZ.

"week_date" || "strict_week_date"

A formatter for a full date as four digit weekyear, two digit week of weekyear, and one digit day of week: xxxx-'W'ww-e.

"week_date_time" || "strict_week_date_time"

A formatter that combines a full weekyear date and time, separated by a T: xxxx-'W'ww-e'T'HH:mm:ss.SSSZZ.

"week_date_time_no_millis" || "strict_week_date_time_no_millis"

A formatter that combines a full weekyear date and time without millis, separated by a T: xxxx-'W'ww-e'T'HH:mm:ssZZ.

"weekyear" || "strict_weekyear"

A formatter for a four digit weekyear: xxxx.

"weekyear_week" || "strict_weekyear_week"

A formatter for a four digit weekyear and two digit week of weekyear: xxxx-'W'ww.

"weekyear_week_day" || "strict_weekyear_week_day"

A formatter for a four digit weekyear, two digit week of weekyear, and one digit day of week: xxxx-'W'ww-e.

"year" || "strict_year"

A formatter for a four digit year: yyyy.

"year_month" || "strict_year_month"

A formatter for a four digit year and two digit month of year: yyyy-MM.

"year_month_day" || "strict_year_month_day"

A formatter for a four digit year, two digit month of year, and two digit day of month: yyyy-MM-dd.

https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html

https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html

type WithFuzziness

type WithFuzziness interface {
	// Fuzziness is the maximum edit distance allowed for matching. See
	// Fuzziness for valid values and more information. See Fuzziness in the
	// match query for an example.
	Fuzziness() string
	// SetFuzziness sets the FuzzinessValue to v
	SetFuzziness(str string)
	// FuzzyRewrite is the method used to rewrite the query. See the rewrite
	// parameter for valid values and more information.
	//
	// If the fuzziness parameter is not 0, the match query uses a fuzzy_rewrite
	// method of top_terms_blended_freqs_${max_expansions} by default.
	FuzzyRewrite() Rewrite
	// SetFuzzyRewrite sets the value of FuzzyRewrite to v
	SetFuzzyRewrite(v Rewrite)
}

WithFuzziness is an interface for queries with fuzziness the parameter

Maximum edit distance allowed for matching. See Fuzziness for valid values and more information.

https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#fuzziness

type WithFuzzyTranspositions

type WithFuzzyTranspositions interface {
	// FuzzyTranspositions edits for fuzzy matching include transpositions of
	// two adjacent characters (ab → ba). Defaults to true
	FuzzyTranspositions() bool
	// SetFuzzyTranspositions sets FuzzyTranspositions to v
	SetFuzzyTranspositions(v bool)
}

WithFuzzyTranspositions is a query with the fuzzy_transpositions param

If true, edits for fuzzy matching include transpositions of two adjacent characters (ab → ba). Defaults to true

type WithLenient

type WithLenient interface {
	// Lenient determines whether format-based errors, such as providing a text
	// query value for a numeric field, are ignored. Defaults to false.
	Lenient() bool
	// SetLenient sets Lenient to v
	SetLenient(v bool)
}

WithLenient is a query with the lenient param

type WithMaxBoost

type WithMaxBoost interface {
	MaxBoost() float64
	SetMaxBoost(v float64)
}

type WithMaxExpansions

type WithMaxExpansions interface {
	// MaxExpansions is the maximum number of variations created. Defaults to 50.
	MaxExpansions() int
	SetMaxExpansions(v int)
}

WithMaxExpansions is a query with the max_expansions param

Maximum number of variations created. Defaults to 50.

WARNING

Avoid using a high value in the max_expansions parameter, especially if the prefix_length parameter value is 0. High values in the max_expansions parameter can cause poor performance due to the high number of variations examined.

type WithMinimumShouldMatch

type WithMinimumShouldMatch interface {
	MinimumShouldMatch() string
	SetMinimumShouldMatch(v string)
}

WithMinimumShouldMatch is a query with the minimum_should_match param

Examples of possible values:

"3"

Integers indicate a fixed value regardless of the number of optional clauses.

"-2"

Negative integers indicate that the total number of optional clauses, minus this number should be mandatory

"75%"

Percentages indicate that this percent of the total number of optional clauses are necessary. The number computed from the percentage is rounded down and used as the minimum.

"-25%"

Negative percentages indicate that this percent of the total number of optional clauses can be missing. The number computed from the percentage is rounded down, before being subtracted from the total to determine the minimum.

"3<90%"

A positive integer, followed by the less-than symbol, followed by any of the previously mentioned specifiers is a conditional specification. It indicates that if the number of optional clauses is equal to (or less than) the integer, they are all required, but if it’s greater than the integer, the specification applies. In this example: if there are 1 to 3 clauses they are all required, but for 4 or more clauses only 90% are required.

"2<-25% 9<-3"

Multiple conditional specifications can be separated by spaces, each one only being valid for numbers greater than the one before it. In this example: if there are 1 or 2 clauses both are required, if there are 3-9 clauses all but 25% are required, and if there are more than 9 clauses, all but three are required.

Note

When dealing with percentages, negative values can be used to get different behavior in edge cases. 75% and -25% mean the same thing when dealing with 4 clauses, but when dealing with 5 clauses 75% means 3 are required, but -25% means 4 are required.

If the calculations based on the specification determine that no optional clauses are needed, the usual rules about BooleanQueries still apply at search time (a BooleanQuery containing no required clauses must still match at least one optional clause)

No matter what number the calculation arrives at, a value greater than the number of optional clauses, or a value less than 1 will never be used. (ie: no matter how low or how high the result of the calculation result is, the minimum number of required matches will never be lower than 1 or greater than the number of clauses.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-minimum-should-match.html

type WithName

type WithName interface {
	Name() string
	SetName(string)
}

type WithOperator

type WithOperator interface {
	// Operator is the boolean logic used to interpret text in the query value.
	// Defaults to Or
	Operator() Operator
	// SetOperator sets the Operator to v
	SetOperator(v Operator)
}

WithOperator is a query with the operator param

Boolean logic used to interpret text in the query value.

type WithPrefixLength

type WithPrefixLength interface {
	PrefixLength() int
	SetPrefixLength(v int)
}

type WithRelation

type WithRelation interface {
	Relation() Relation
	SetRelation(v Relation)
}

type WithRewrite

type WithRewrite interface {
	Rewrite() Rewrite
	SetRewrite(v Rewrite)
}

WithRewrite is a query with the rewrite param

type WithSlop

type WithSlop interface {
	Slop() int
	SetSlop(v int)
}

type WithTimeZone

type WithTimeZone interface {
	TimeZone() string
	SetTimeZone(v string)
}

type WithTranspositions

type WithTranspositions interface {
	// Transpositions indicates whether edits include transpositions of two
	// adjacent characters (ab → ba). Defaults to true.
	Transpositions() bool
	// SetTranspositions sets the value of Transpositions to v
	SetTranspositions(v bool)
}

WithTranspositions is an interface for queries with the transpositions param

(Optional, Boolean) Indicates whether edits include transpositions of two adjacent characters (ab → ba). Defaults to true.

type WithZeroTermsQuery

type WithZeroTermsQuery interface {
	// ZeroTermsQuery indicates  whether no documents are returned if the
	// analyzer removes all tokens, such as when using a stop filter
	ZeroTermsQuery() ZeroTermsQuery
	SetZeroTermsQuery(v ZeroTermsQuery)
}

type ZeroTermsQuery

type ZeroTermsQuery string
const (
	// ZeroTermsQueryNone - No documents are returned if the analyzer removes all
	// tokens.
	ZeroTermsQueryNone ZeroTermsQuery = "none"
	// ZeroTermsALl - Returns all documents, similar to a match_all query.
	ZeroTermsQueryAll ZeroTermsQuery = "all"
)

type ZeroTermsQueryParam

type ZeroTermsQueryParam struct {
	ZeroTermsQueryValue *ZeroTermsQuery `json:"zero_terms_query,omitempty" bson:"zero_terms_query,omitempty"`
}

func (*ZeroTermsQueryParam) SetZeroTermsQuery

func (ztq *ZeroTermsQueryParam) SetZeroTermsQuery(v ZeroTermsQuery)

func (ZeroTermsQueryParam) ZeroTermsQuery

func (ztq ZeroTermsQueryParam) ZeroTermsQuery() ZeroTermsQuery

ZeroTermsQuery indicates whether no documents are returned if the analyzer removes all tokens, such as when using a stop filter

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html#query-dsl-match-query-zero

Jump to

Keyboard shortcuts

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