query

package
v1.43.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Term      string = "Term={{.Term}};"
	Now       string = "Now={{.Now}};"
	Size      string = "Size={{.Size}};"
	Highlight string = "Highlight={{.Highlight}};"
	From      string = "From={{.From}};"
)
View Source
const (
	Separator   = ","
	EmptyClause = `{}`

	NoProvisionalNoConfirmedPostponed = `
{"term":{"finalised":true}}, {"exists":{"field":"date_changes"}}
`

	NoProvisionalConfirmedNoPostponed = `
{"term":{"finalised":true}}, {"bool":{"must_not":{"exists":{"field":"date_changes"}}}}
`

	NoProvisionalConfirmedPostponed = `
{"term":{"finalised":true}}
`

	ProvisionalNoConfirmedNoPostponed = `
{"term":{"finalised":false}}
`

	ProvisionalNoConfirmedPostponed = `` /* 215-byte string literal not displayed */

	ProvisionalConfirmedNoPostponed = `` /* 237-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func FormatMultiQuery

func FormatMultiQuery(rawQuery []byte) ([]byte, error)

FormatMultiQuery minifies and reformats an elasticsearch MultiQuery

func LegacyFormatMultiQuery

func LegacyFormatMultiQuery(rawQuery []byte) ([]byte, error)

LegacyFormatMultiQuery minifies and reformats an elasticsearch MultiQuery

func ParseQuery

func ParseQuery(q string) (s1, s2 string)

ParseQuery :

escapes double quotes (") in the given query q, so that ElasticSearch will accept them

looks for a prefix in the given query q (which can be used to determine the type of query passed to ElasticSearch)

returns the escaped query with the prefix removed (if any was prefixed), together with the name of the template to use to generate the ElasticSearch query

func SetupSearch

func SetupSearch() (*template.Template, error)

SetupSearch loads templates for use by the search handler and should be done only once

func SetupV710Count added in v1.32.0

func SetupV710Count() (*template.Template, error)

SetupV710Search loads v710 templates for use by the search handler and should be done only once

func SetupV710Search

func SetupV710Search() (*template.Template, error)

SetupV710Search loads v710 templates for use by the search handler and should be done only once

Types

type AggregationFields added in v1.34.0

type AggregationFields struct {
	Topics          string
	ContentTypes    string
	PopulationTypes string
	Dimensions      string
}

AggregationFields are the elasticsearch keys for which the aggregations will be done

type Builder

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

Builder represents an instance of a query builder

func NewQueryBuilder

func NewQueryBuilder() (*Builder, error)

NewQueryBuilder loads the elastic search templates and returns a query builder instance

func (*Builder) AddNlpCategorySearch added in v1.43.0

func (sb *Builder) AddNlpCategorySearch(nlpCriteria *NlpCriteria, category, subCategory string, categoryWeighting float32) *NlpCriteria

func (*Builder) AddNlpSubdivisionSearch added in v1.43.0

func (sb *Builder) AddNlpSubdivisionSearch(nlpCriteria *NlpCriteria, subdivisionWords string) *NlpCriteria

func (*Builder) BuildCountQuery added in v1.32.0

func (sb *Builder) BuildCountQuery(_ context.Context, reqParams *CountRequest) ([]byte, error)

BuildSearchQuery creates an elastic search query from the provided search parameters

func (*Builder) BuildSearchQuery

func (sb *Builder) BuildSearchQuery(_ context.Context, reqParams *SearchRequest, esVersion710 bool) ([]byte, error)

BuildSearchQuery creates an elastic search query from the provided search parameters

type CountRequest added in v1.34.0

type CountRequest struct {
	Term        string
	CountEnable bool
}

type Date

type Date time.Time

func MustParseDate

func MustParseDate(date string) Date

func ParseDate

func ParseDate(date string) (Date, error)

func (Date) ESString

func (d Date) ESString() string

func (Date) Set

func (d Date) Set() bool

func (Date) String

func (d Date) String() string

type DimensionRequest added in v1.34.0

type DimensionRequest struct {
	Key      string
	AggKey   string
	Name     string
	Label    string
	RawLabel string
}

type InvalidDateString

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

func (InvalidDateString) Error

func (ids InvalidDateString) Error() string

type InvalidReleaseTypeString

type InvalidReleaseTypeString string

func (InvalidReleaseTypeString) Error

func (irts InvalidReleaseTypeString) Error() string

type InvalidSortString

type InvalidSortString string

func (InvalidSortString) Error

func (iss InvalidSortString) Error() string

type NlpCriteria added in v1.43.0

type NlpCriteria struct {
	UseCategory      bool
	Categories       []NlpCriteriaCategory
	UseSubdivision   bool
	SubdivisionWords string
}

type NlpCriteriaCategory added in v1.43.0

type NlpCriteriaCategory struct {
	Category    string
	SubCategory string
	Weighting   float32
}

type NlpSettings added in v1.43.0

type NlpSettings struct {
	CategoryWeighting float32 `json:"category_weighting"`
	CategoryLimit     int     `json:"category_limit"`
	DefaultState      string  `json:"default_state"`
}

type ParamValidator

type ParamValidator map[paramName]validator

ParamValidator is a map of parameters to their corresponding validator func

func NewReleaseQueryParamValidator

func NewReleaseQueryParamValidator() ParamValidator

NewReleaseQueryParamValidator creates a validator to validate parameters for the Release endpoint

func NewSearchQueryParamValidator added in v1.34.0

func NewSearchQueryParamValidator() ParamValidator

NewSearchQueryParamValidator creates a validator to validate parameters for the Search endpoint

func (ParamValidator) Validate

func (qpv ParamValidator) Validate(_ context.Context, name, value string) (interface{}, error)

Validate calls the validator func for the provided parameter name and value

type PopulationTypeRequest added in v1.34.0

type PopulationTypeRequest struct {
	Key    string
	AggKey string
	Name   string
	Label  string
}

type ReleaseBuilder

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

func NewReleaseBuilder

func NewReleaseBuilder() (*ReleaseBuilder, error)

func (*ReleaseBuilder) BuildSearchQuery

func (rb *ReleaseBuilder) BuildSearchQuery(_ context.Context, searchRequest interface{}) ([]esClient.Search, error)

BuildSearchQuery builds an elastic search query from the provided search parameters for Release Calendars

type ReleaseSearchRequest

type ReleaseSearchRequest struct {
	Term           string
	Template       string
	From           int
	Size           int
	SortBy         Sort
	ReleasedAfter  Date
	ReleasedBefore Date
	Type           ReleaseType
	Provisional    bool
	Confirmed      bool
	Postponed      bool
	Census         bool
	Highlight      bool
}

func (ReleaseSearchRequest) CensusClause

func (sr ReleaseSearchRequest) CensusClause() string

func (ReleaseSearchRequest) HighlightClause

func (sr ReleaseSearchRequest) HighlightClause() string

func (ReleaseSearchRequest) Now

func (sr ReleaseSearchRequest) Now() string

func (ReleaseSearchRequest) ReleaseTypeClause

func (sr ReleaseSearchRequest) ReleaseTypeClause() string

ReleaseTypeClause returns the query clause to select the type of release Note that it is possible for a Release to have both its Published and Cancelled flags true (yes indeed!) In this case it is deemed cancelled

func (*ReleaseSearchRequest) Set

func (sr *ReleaseSearchRequest) Set(value string) error

func (ReleaseSearchRequest) SortClause

func (sr ReleaseSearchRequest) SortClause() string

func (*ReleaseSearchRequest) String

func (sr *ReleaseSearchRequest) String() string

type ReleaseType

type ReleaseType int
const (
	InvalidReleaseType ReleaseType = iota
	Upcoming
	Published
	Cancelled
)

func MustParseReleaseType

func MustParseReleaseType(s string) ReleaseType

func ParseReleaseType

func ParseReleaseType(s string) (ReleaseType, error)

func (ReleaseType) String

func (rt ReleaseType) String() string

type SearchRequest added in v1.34.0

type SearchRequest struct {
	Term                string
	From                int
	Size                int
	Types               []string
	Index               string
	SortBy              string
	ReleasedAfter       Date
	ReleasedBefore      Date
	AggregationField    string // Deprecated (used only in legacy templates for aggregations)
	AggregationFields   *AggregationFields
	Highlight           bool
	URIPrefix           string
	NlpCategories       []NlpCriteriaCategory
	NlpSubdivisionWords string
	Topic               []string
	TopicWildcard       []string
	PopulationTypes     []*PopulationTypeRequest
	Dimensions          []*DimensionRequest
	Now                 string
}

SearchRequest holds the values provided by a request against Search API The values are used to build the elasticsearch query using the corresponding template/s

type Sort

type Sort int
const (
	Invalid Sort = iota
	RelDateAsc
	RelDateDesc
	TitleAsc
	TitleDesc
	Relevance
)

func ParseSort

func ParseSort(sort string) (Sort, error)

func (Sort) ESString

func (s Sort) ESString() string

func (Sort) String

func (s Sort) String() string

Directories

Path Synopsis
templates

Jump to

Keyboard shortcuts

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