query

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool func(o ...func(*BoolParam)) map[string]interface{}

func NewBool

func NewBool() Bool

func (Bool) WithBoost

func (b Bool) WithBoost(boost float32) func(*BoolParam)

default 1.0

func (Bool) WithClause

func (b Bool) WithClause(clauseType ClauseType, queries ...map[string]interface{}) func(*BoolParam)

func (Bool) WithMinShouldMatch

func (b Bool) WithMinShouldMatch(minimumShouldMatch string) func(*BoolParam)

func (Bool) WithName

func (b Bool) WithName(name string) func(*BoolParam)

type BoolParam

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

func (*BoolParam) Build

func (b *BoolParam) Build() map[string]interface{}

type Boosting

type Boosting func(positive, negative map[string]interface{}, negativeBoost float32, o ...func(*BoostingParam)) map[string]interface{}

func NewBoosting

func NewBoosting() Boosting

func (Boosting) WithBoost

func (b Boosting) WithBoost(boost float32) func(*BoostingParam)

default 1.0

func (Boosting) WithName

func (b Boosting) WithName(name string) func(*BoostingParam)

type BoostingParam

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

func (*BoostingParam) Build

func (b *BoostingParam) Build() map[string]interface{}

type ClauseType

type ClauseType string
const (
	ClauseTypeMust    ClauseType = "must"
	ClauseTypeMustNot ClauseType = "must_not"
	ClauseTypeShould  ClauseType = "should"
	ClauseTypeFilter  ClauseType = "filter"
)

type CombinedFields

type CombinedFields func(fields []string, text string, o ...func(*CombinedFieldsParam)) map[string]interface{}

func NewCombinedFields

func NewCombinedFields() CombinedFields

func (CombinedFields) WithBoost

func (c CombinedFields) WithBoost(boost float32) func(*CombinedFieldsParam)

default 1.0

func (CombinedFields) WithMinShouldMatch

func (c CombinedFields) WithMinShouldMatch(minimumShouldMatch string) func(*CombinedFieldsParam)

func (CombinedFields) WithName

func (c CombinedFields) WithName(name string) func(*CombinedFieldsParam)

func (CombinedFields) WithOperator

func (c CombinedFields) WithOperator(operator string) func(*CombinedFieldsParam)

default OR

func (CombinedFields) WithZeroTermsQuery

func (c CombinedFields) WithZeroTermsQuery(zeroTermsQuery string) func(*CombinedFieldsParam)

default none

type CombinedFieldsParam

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

func (*CombinedFieldsParam) Build

func (c *CombinedFieldsParam) Build() map[string]interface{}

type CompareOperator

type CompareOperator string
const (
	CompareOperatorGT  CompareOperator = "gt"
	CompareOperatorGTE CompareOperator = "gte"
	CompareOperatorLT  CompareOperator = "lt"
	CompareOperatorLTE CompareOperator = "lte"
)

type ConstantScore

type ConstantScore func(filter map[string]interface{}, o ...func(*ConstantScoreParam)) map[string]interface{}

func NewConstantScore

func NewConstantScore() ConstantScore

func (ConstantScore) WithBoost

func (c ConstantScore) WithBoost(boost float32) func(*ConstantScoreParam)

default 1.0

func (ConstantScore) WithName

func (c ConstantScore) WithName(name string) func(*ConstantScoreParam)

type ConstantScoreParam

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

func (*ConstantScoreParam) Build

func (c *ConstantScoreParam) Build() map[string]interface{}

type DisjunctionMax

type DisjunctionMax func(queries []map[string]interface{}, o ...func(*DisjunctionMaxParam)) map[string]interface{}

func NewDisjunctionMax

func NewDisjunctionMax() DisjunctionMax

func (DisjunctionMax) WithBoost

func (d DisjunctionMax) WithBoost(boost float32) func(*DisjunctionMaxParam)

default 1.0

func (DisjunctionMax) WithName

func (d DisjunctionMax) WithName(name string) func(*DisjunctionMaxParam)

func (DisjunctionMax) WithTieBreaker

func (d DisjunctionMax) WithTieBreaker(tieBreaker float32) func(*DisjunctionMaxParam)

default 0

type DisjunctionMaxParam

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

func (*DisjunctionMaxParam) Build

func (d *DisjunctionMaxParam) Build() map[string]interface{}

type Exists

type Exists func(field string) map[string]interface{}

func NewExists

func NewExists() Exists

type Flag

type Flag string
const (
	//Enables the + AND operator.
	And Flag = "AND"
	//Enables \ as an escape character.
	Escape Flag = "ESCAPE"
	//Enables the ~N operator after a word, where N is an integer denoting the allowed edit distance for matching. See Fuzziness.
	Fuzzy Flag = "FUZZY"
	//Enables the ~N operator, after a phrase where N is the maximum number of positions allowed between matching tokens. Synonymous to SLOP.
	Near Flag = "NEAR"
	//Disables all operators.
	None Flag = "NONE"
	//Enables the - NOT operator.
	Not Flag = "NOT"
	//Enables the \| OR operator.
	Or Flag = "OR"
	//Enables the " quotes operator used to search for phrases.
	Phrase Flag = "PHRASE"
	//Enables the ( and ) operators to control operator precedence.
	Precedence Flag = "PRECEDENCE"
	//Enables the * prefix operator.
	Prefix Flag = "PREFIX"
	//Enables the ~N operator, after a phrase where N is maximum number of positions allowed between matching tokens. Synonymous to NEAR.
	Slop Flag = "SLOP"
	//Enables whitespace as split characters.
	Whitespace Flag = "WHITESPACE"
)

type IDS

type IDS func(ids []string, o ...func(*IDSParam)) map[string]interface{}

func NewIDS

func NewIDS() IDS

func (IDS) WithBoost

func (i IDS) WithBoost(boost float32) func(*IDSParam)

default 1.0

func (IDS) WithName

func (i IDS) WithName(name string) func(*IDSParam)

type IDSParam

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

func (IDSParam) Build

func (i IDSParam) Build() map[string]interface{}

type Match

type Match func(field, text string, o ...func(*MatchParam)) map[string]interface{}

func NewMatch

func NewMatch() Match

func (Match) WithAnalyzer

func (m Match) WithAnalyzer(analyzer string) func(*MatchParam)

default analysis.analyzer.default or standard analyzer

func (Match) WithBoost

func (m Match) WithBoost(boost float32) func(*MatchParam)

default 1.0

func (Match) WithMinShouldMatch

func (m Match) WithMinShouldMatch(minimumShouldMatch string) func(*MatchParam)

func (Match) WithName

func (m Match) WithName(name string) func(*MatchParam)

func (Match) WithOperator

func (m Match) WithOperator(operator string) func(*MatchParam)

default OR

func (Match) WithZeroTermsQuery

func (m Match) WithZeroTermsQuery(zeroTermsQuery string) func(*MatchParam)

default none

type MatchAll

type MatchAll func(o ...func(*MatchAllParam)) map[string]interface{}

func NewMatchAll

func NewMatchAll() MatchAll

func (MatchAll) WithBoost

func (m MatchAll) WithBoost(boost float32) func(*MatchAllParam)

default 1.0

func (MatchAll) WithName

func (m MatchAll) WithName(name string) func(*MatchAllParam)

type MatchAllParam

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

func (*MatchAllParam) Build

func (m *MatchAllParam) Build() map[string]interface{}

type MatchBoolPrefix

type MatchBoolPrefix func(field, text string, o ...func(*MatchBoolPrefixParam)) map[string]interface{}

func NewMatchBoolPrefix

func NewMatchBoolPrefix() MatchBoolPrefix

func (MatchBoolPrefix) WithAnalyzer

func (m MatchBoolPrefix) WithAnalyzer(analyzer string) func(*MatchBoolPrefixParam)

default analysis.analyzer.default or standard analyzer

func (MatchBoolPrefix) WithBoost

func (m MatchBoolPrefix) WithBoost(boost float32) func(*MatchBoolPrefixParam)

default 1.0

func (MatchBoolPrefix) WithMinShouldMatch

func (m MatchBoolPrefix) WithMinShouldMatch(minimumShouldMatch string) func(*MatchBoolPrefixParam)

func (MatchBoolPrefix) WithName

func (m MatchBoolPrefix) WithName(name string) func(*MatchBoolPrefixParam)

func (MatchBoolPrefix) WithOperator

func (m MatchBoolPrefix) WithOperator(operator string) func(*MatchBoolPrefixParam)

default OR

type MatchBoolPrefixParam

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

func (*MatchBoolPrefixParam) Build

func (m *MatchBoolPrefixParam) Build() map[string]interface{}

type MatchParam

type MatchParam struct {
	// contains filtered or unexported fields
}
func (m Match) WithOperator(operator string)func(*MatchParam){
	return func(p *MatchParam) {

	}
}

func (*MatchParam) Build

func (m *MatchParam) Build() map[string]interface{}
{
	"match":{
		<field>:{
			"query":<text>,
			...
		}
	}
}

or

{
	"match":{
		<field>:<text>,
	}
}

type MatchPhrase

type MatchPhrase func(field, text string, o ...func(*MatchPhraseParam)) map[string]interface{}

func NewMatchPhrase

func NewMatchPhrase() MatchPhrase

func (MatchPhrase) WithAnalyzer

func (m MatchPhrase) WithAnalyzer(analyzer string) func(*MatchPhraseParam)

default analysis.analyzer.default or standard analyzer

func (MatchPhrase) WithBoost

func (m MatchPhrase) WithBoost(boost float32) func(*MatchPhraseParam)

default 1.0

func (MatchPhrase) WithName

func (m MatchPhrase) WithName(name string) func(*MatchPhraseParam)

func (MatchPhrase) WithSlop

func (m MatchPhrase) WithSlop(slop int) func(*MatchPhraseParam)

default 0

func (MatchPhrase) WithZeroTermsQuery

func (m MatchPhrase) WithZeroTermsQuery(zeroTermsQuery string) func(*MatchPhraseParam)

default none

type MatchPhraseParam

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

func (*MatchPhraseParam) Build

func (m *MatchPhraseParam) Build() map[string]interface{}
{
	"match_phrase":{
		<field>:{
			"query":<text>,
			...
		}
	}
}

or

{
	"match_phrase":{
		<field>:<text>,
	}
}

type MatchPhrasePrefix

type MatchPhrasePrefix func(field, text string, o ...func(*MatchPhrasePrefixParam)) map[string]interface{}

func NewMatchPhrasePrefix

func NewMatchPhrasePrefix() MatchPhrasePrefix

func (MatchPhrasePrefix) WithAnalyzer

func (m MatchPhrasePrefix) WithAnalyzer(analyzer string) func(*MatchPhrasePrefixParam)

default analysis.analyzer.default or standard analyzer

func (MatchPhrasePrefix) WithBoost

func (m MatchPhrasePrefix) WithBoost(boost float32) func(*MatchPhrasePrefixParam)

default 1.0

func (MatchPhrasePrefix) WithName

func (m MatchPhrasePrefix) WithName(name string) func(*MatchPhrasePrefixParam)

func (MatchPhrasePrefix) WithSlop

func (m MatchPhrasePrefix) WithSlop(slop int) func(*MatchPhrasePrefixParam)

default 0

func (MatchPhrasePrefix) WithZeroTermsQuery

func (m MatchPhrasePrefix) WithZeroTermsQuery(zeroTermsQuery string) func(*MatchPhrasePrefixParam)

default none

type MatchPhrasePrefixParam

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

func (*MatchPhrasePrefixParam) Build

func (m *MatchPhrasePrefixParam) Build() map[string]interface{}

type MultiMatch

type MultiMatch func(text string, o ...func(*MultiMatchParam)) map[string]interface{}

func NewMultiMatch

func NewMultiMatch() MultiMatch

func (MultiMatch) WithAnalyzer

func (m MultiMatch) WithAnalyzer(analyzer string) func(*MultiMatchParam)

default analysis.analyzer.default or standard analyzer

func (MultiMatch) WithBoost

func (m MultiMatch) WithBoost(boost float32) func(*MultiMatchParam)

default 1.0

func (MultiMatch) WithFields

func (m MultiMatch) WithFields(fields ...string) func(*MultiMatchParam)

default index.query.default_field or *.*

func (MultiMatch) WithMinShouldMatch

func (m MultiMatch) WithMinShouldMatch(minimumShouldMatch string) func(*MultiMatchParam)

func (MultiMatch) WithName

func (m MultiMatch) WithName(name string) func(*MultiMatchParam)

func (MultiMatch) WithOperator

func (m MultiMatch) WithOperator(operator string) func(*MultiMatchParam)

default OR

func (MultiMatch) WithTieBreaker

func (m MultiMatch) WithTieBreaker(tieBreaker float32) func(*MultiMatchParam)

default 0

func (MultiMatch) WithType

func (m MultiMatch) WithType(matchType MultiMatchType) func(*MultiMatchParam)

default best_fields

func (MultiMatch) WithZeroTermsQuery

func (m MultiMatch) WithZeroTermsQuery(zeroTermsQuery string) func(*MultiMatchParam)

default none

type MultiMatchParam

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

func (*MultiMatchParam) Build

func (m *MultiMatchParam) Build() map[string]interface{}
{
   "multi_match" : {
     "query": <text>,
     "fields":<fields>
		...
   }
}

type MultiMatchType

type MultiMatchType string
const (

	//Finds documents which match any field, but uses the _score from the best field.
	MultiMatchTypeBestFields MultiMatchType = "best_fields"
	//Finds documents which match any field and combines the _score from each field
	MultiMatchTypeMostFields MultiMatchType = "most_fields"
	//Treats fields with the same analyzer as though they were one big field. Looks for each word in any field
	MultiMatchTypeCrossFields MultiMatchType = "cross_fields"
	//Runs a match_phrase query on each field and uses the _score from the best field.
	MultiMatchTypePhrase MultiMatchType = "phrase"
	//Runs a match_phrase_prefix query on each field and uses the _score from the best field
	MultiMatchTypePhrasePrefix MultiMatchType = "phrase_prefix"
	//Creates a match_bool_prefix query on each field and combines the _score from each field.
	MultiMatchTypeBoolPrefix MultiMatchType = "bool_prefix"
)

type Nested

type Nested func(path string, query map[string]interface{}, o ...func(param *NestedParam)) map[string]interface{}

func NewNested

func NewNested() Nested

func (Nested) WithName

func (n Nested) WithName(name string) func(*NestedParam)

func (Nested) WithReturn

func (n Nested) WithReturn(whetherReturn bool) func(*NestedParam)

func (Nested) WithSource

func (n Nested) WithSource(source map[string]interface{}) func(*NestedParam)

type NestedParam

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

func (*NestedParam) Build

func (n *NestedParam) Build() map[string]interface{}

type Range

type Range func(field string, o ...func(*RangeParam)) map[string]interface{}

func NewRange

func NewRange() Range

func (Range) WithBoost

func (r Range) WithBoost(boost float32) func(*RangeParam)

default 1.0

func (Range) WithCompareOperate

func (r Range) WithCompareOperate(operator CompareOperator, value interface{}) func(*RangeParam)

func (Range) WithDateFormat

func (r Range) WithDateFormat(dateFormat string) func(*RangeParam)

func (Range) WithName

func (r Range) WithName(name string) func(*RangeParam)

func (Range) WithRelation

func (r Range) WithRelation(relation RelationType) func(*RangeParam)

default Intersects

func (Range) WithTimeZone

func (r Range) WithTimeZone(timeZone string) func(*RangeParam)

type RangeParam

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

func (*RangeParam) Build

func (r *RangeParam) Build() map[string]interface{}

type RelationType

type RelationType string
const (
	//Matches documents with a range field value that intersects the query’s range.
	Intersects RelationType = "INTERSECTS"
	//Matches documents with a range field value that entirely contains the query’s range.
	Contains RelationType = "CONTAINS"
	//Matches documents with a range field value entirely within the query’s range.
	Within RelationType = "WITHIN"
)

type Script

type Script func(script func(*ScriptParam), o ...func(*ScriptParam)) map[string]interface{}

func NewScript

func NewScript() Script

func (Script) WithLang

func (s Script) WithLang(lang string) func(*ScriptParam)

func (Script) WithScriptId

func (s Script) WithScriptId(id string, params map[string]interface{}) func(*ScriptParam)

func (Script) WithScriptSource

func (s Script) WithScriptSource(source string, params map[string]interface{}) func(*ScriptParam)

type ScriptParam

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

func (*ScriptParam) Build

func (s *ScriptParam) Build() map[string]interface{}

type SimpleQueryString

type SimpleQueryString func(text string, o ...func(*SimpleQueryStringParam)) map[string]interface{}

func NewSimpleQueryString

func NewSimpleQueryString() SimpleQueryString

func (SimpleQueryString) WithAnalyzer

func (s SimpleQueryString) WithAnalyzer(analyzer string) func(*SimpleQueryStringParam)

default analysis.analyzer.default or standard analyzer

func (SimpleQueryString) WithAnalyzerWildcard

func (s SimpleQueryString) WithAnalyzerWildcard(analyzerWildcard bool) func(*SimpleQueryStringParam)

default false

func (SimpleQueryString) WithBoost

func (s SimpleQueryString) WithBoost(boost float32) func(*SimpleQueryStringParam)

default 1.0

func (SimpleQueryString) WithDefaultOperator

func (s SimpleQueryString) WithDefaultOperator(defaultOperator string) func(*SimpleQueryStringParam)

default OR

func (SimpleQueryString) WithFields

func (s SimpleQueryString) WithFields(fields ...string) func(*SimpleQueryStringParam)

default index.query.default_field or *

func (SimpleQueryString) WithFlags

func (s SimpleQueryString) WithFlags(flags ...Flag) func(*SimpleQueryStringParam)

default All

func (SimpleQueryString) WithMinShouldMatch

func (s SimpleQueryString) WithMinShouldMatch(minimumShouldMatch string) func(*SimpleQueryStringParam)

func (SimpleQueryString) WithName

func (s SimpleQueryString) WithName(name string) func(*SimpleQueryStringParam)

type SimpleQueryStringParam

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

func (*SimpleQueryStringParam) Build

func (s *SimpleQueryStringParam) Build() map[string]interface{}

type Sort

type Sort func(o ...func(*SortParam)) map[string]interface{}

func NewSort

func NewSort() Sort

TODO not finished

func (Sort) WithOrder

func (s Sort) WithOrder(field string, order interface{}) func(*SortParam)

type SortParam

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

func (*SortParam) Build

func (s *SortParam) Build() map[string]interface{}

type Source

type Source func(o ...func(*SourceParam)) map[string]interface{}

func NewSource

func NewSource() Source

TODO not finished

func (Source) WithExcludes

func (s Source) WithExcludes(fields ...string) func(*SourceParam)

func (Source) WithIncludes

func (s Source) WithIncludes(fields ...string) func(*SourceParam)

type SourceParam

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

func (*SourceParam) Build

func (s *SourceParam) Build() map[string]interface{}

type Term

type Term func(field, value string, o ...func(*TermParam)) map[string]interface{}
{
	"term":{
		<field>:<value>
	}
}

or

{
	"term":{
		<field>:{
			"value":<value>,
			"boost":<boost>,
			"case_insensitive":<caseInsensitive>
		}
	}
}

func NewTerm

func NewTerm() Term

func (Term) WithBoost

func (t Term) WithBoost(boost float32) func(*TermParam)

default 1.0

func (Term) WithCaseInsensitive

func (t Term) WithCaseInsensitive(caseInsensitive bool) func(*TermParam)

default false

func (Term) WithName

func (t Term) WithName(name string) func(*TermParam)

type TermParam

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

func (*TermParam) Build

func (t *TermParam) Build() map[string]interface{}

type Terms

type Terms func(field string, o ...func(*TermsParam)) map[string]interface{}
{
	"terms":{
		<field>:[<value>...],
     "boost":<boost>,
	}
}

or

{
	"terms":{
		<field>:{
			"index":<index>,
			"id":<id>,
			"path":<path>,
			"routing":<routing>
		},
		"boost":<boost>
	}
}

func NewTerms

func NewTerms() Terms

func (Terms) WithBoost

func (t Terms) WithBoost(boost float32) func(*TermsParam)

default 1.0

func (Terms) WithLookUp

func (t Terms) WithLookUp(index, id, path, routing string) func(*TermsParam)

func (Terms) WithName

func (t Terms) WithName(name string) func(*TermsParam)

func (Terms) WithValue

func (t Terms) WithValue(value ...interface{}) func(*TermsParam)

type TermsParam

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

func (*TermsParam) Build

func (t *TermsParam) Build() map[string]interface{}

Jump to

Keyboard shortcuts

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