Documentation ¶
Index ¶
- Variables
- func FromLoggerContext(ctx context.Context) (*time.Time, error)
- func NewContext(ctx context.Context, rsQuery RSQuery) context.Context
- func NewLoggerContext(ctx context.Context) context.Context
- type DataField
- type FunctionObject
- type GeoBoundingBox
- type GeoValue
- type Query
- type QueryEnvs
- type QueryFormat
- type QueryTranslate
- type QueryType
- type RSQuery
- type RangeValue
- type RankFunction
- type Settings
- type SortBy
- type TermFilter
Constants ¶
This section is empty.
Variables ¶
var EXCEPTION_KEYS_IN_QUERY = []string{"size", "from", "aggs", "_source", "sort", "query"}
EXCEPTION_KEYS_IN_QUERY represents the keys which will not get copied while combining the queries using `react` prop
var RESERVED_KEYS_IN_RESPONSE = []string{"settings", "error"}
Functions ¶
func FromLoggerContext ¶
FromContext retrieves the rs api request stored against the querytranslate.loggerCtxKey from the context.
func NewContext ¶
NewContext returns a new context with the given request body.
Types ¶
type DataField ¶
func NormalizedDataFields ¶
The `dataField` property can be of following types - string - `DataField` struct with `field` and `weight` keys - Array of strings - Array of `DataField` struct - Array of strings and `DataField` struct
The following method normalizes the dataField input into a array of strings It also supports the fieldWeights in old format
func ParseDataFieldToString ¶
To construct the data field string with field weight from `DataField` struct
type FunctionObject ¶
type GeoBoundingBox ¶
type GeoValue ¶
type GeoValue struct { Distance *int Unit *string Location *string BoundingBox *GeoBoundingBox }
type Query ¶
type Query struct { ID *string `json:"id,omitempty"` // component id Type QueryType `json:"type,omitempty"` React *map[string]interface{} `json:"react,omitempty"` QueryFormat *QueryFormat `json:"queryFormat,omitempty"` DataField interface{} `json:"dataField,omitempty"` CategoryField *string `json:"categoryField,omitempty"` CategoryValue *interface{} `json:"categoryValue,omitempty"` FieldWeights []float64 `json:"fieldWeights,omitempty"` NestedField *string `json:"nestedField,omitempty"` From *int `json:"from,omitempty"` Size *int `json:"size,omitempty"` AggregationSize *int `json:"aggregationSize,omitempty"` SortBy *SortBy `json:"sortBy,omitempty"` Value *interface{} `json:"value,omitempty"` // either string or Array of string AggregationField *string `json:"aggregationField,omitempty"` After *map[string]interface{} `json:"after,omitempty"` IncludeNullValues *bool `json:"includeNullValues,omitempty"` IncludeFields *[]string `json:"includeFields,omitempty"` ExcludeFields *[]string `json:"excludeFields,omitempty"` Fuzziness interface{} `json:"fuzziness,omitempty"` // string or int SearchOperators *bool `json:"searchOperators,omitempty"` Highlight *bool `json:"highlight,omitempty"` HighlightField []string `json:"highlightField,omitempty"` CustomHighlight *map[string]interface{} `json:"customHighlight,omitempty"` Interval *int `json:"interval,omitempty"` Aggregations *[]string `json:"aggregations,omitempty"` MissingLabel string `json:"missingLabel,omitempty"` ShowMissing bool `json:"showMissing,omitempty"` DefaultQuery *map[string]interface{} `json:"defaultQuery,omitempty"` CustomQuery *map[string]interface{} `json:"customQuery,omitempty"` Execute *bool `json:"execute,omitempty"` EnableSynonyms *bool `json:"enableSynonyms,omitempty"` SelectAllLabel *string `json:"selectAllLabel,omitempty"` Pagination *bool `json:"pagination,omitempty"` QueryString *bool `json:"queryString,omitempty"` RankFeature *map[string]RankFunction `json:"rankFeature,omitempty"` DistinctField *string `json:"distinctField,omitempty"` DistinctFieldConfig *map[string]interface{} `json:"distinctFieldConfig,omitempty"` Index *string `json:"index,omitempty"` }
Query represents the query object
type QueryEnvs ¶
type QueryEnvs struct { Query *string TermFilters []TermFilter }
QueryEnvs represents the extracted values from RSQuery
func ExtractEnvsFromRequest ¶
ExtractEnvsFromRequest returns the extracted values from RS request
type QueryFormat ¶
type QueryFormat int
const ( Or QueryFormat = iota And )
func (QueryFormat) MarshalJSON ¶
func (o QueryFormat) MarshalJSON() ([]byte, error)
MarshalJSON is the implementation of the Marshaler interface for marshaling QueryFormat type.
func (QueryFormat) String ¶
func (o QueryFormat) String() string
String is the implementation of Stringer interface that returns the string representation of QueryFormat type.
func (*QueryFormat) UnmarshalJSON ¶
func (o *QueryFormat) UnmarshalJSON(bytes []byte) error
UnmarshalJSON is the implementation of the Unmarshaler interface for unmarshaling QueryFormat type.
type QueryTranslate ¶
type QueryTranslate struct{}
QueryTranslate plugin deals with managing query translation.
func Instance ¶
func Instance() *QueryTranslate
Instance returns the singleton instance of the plugin. Instance should be the only way (both within or outside the package) to fetch the instance of the plugin, in order to avoid stateless duplicates.
func (*QueryTranslate) ESMiddleware ¶
func (r *QueryTranslate) ESMiddleware() []middleware.Middleware
func (*QueryTranslate) InitFunc ¶
func (r *QueryTranslate) InitFunc(mw []middleware.Middleware) error
InitFunc initializes the dao, i.e. elasticsearch client, and should be executed only once in the lifetime of the plugin.
func (*QueryTranslate) Name ¶
func (r *QueryTranslate) Name() string
Name returns the name of the plugin: querytranslate
func (*QueryTranslate) Routes ¶
func (r *QueryTranslate) Routes() []plugins.Route
Routes returns an empty slices since the plugin solely acts as a middleware.
type QueryType ¶
type QueryType int
func (QueryType) MarshalJSON ¶
MarshalJSON is the implementation of the Marshaler interface for marshaling QueryType type.
func (QueryType) String ¶
String is the implementation of Stringer interface that returns the string representation of QueryType type.
func (*QueryType) UnmarshalJSON ¶
UnmarshalJSON is the implementation of the Unmarshaler interface for unmarshaling QueryType type.
type RSQuery ¶
type RSQuery struct { Query []Query `json:"query,omitempty"` Settings *Settings `json:"settings,omitempty"` }
RSQuery represents the request body
type RangeValue ¶
type RangeValue struct { Start *interface{} End *interface{} Boost *float64 }
RangeValue represents the struct of range value
type RankFunction ¶
type RankFunction struct { Saturation *FunctionObject `json:"saturation,omitempty"` Logarithm *FunctionObject `json:"log,omitempty"` Sigmoid *FunctionObject `json:"sigmoid,omitempty"` Boost *float64 `json:"boost,omitempty"` }
type Settings ¶
type Settings struct { RecordAnalytics *bool `json:"recordAnalytics,omitempty"` UserID *string `json:"userId,omitempty"` CustomEvents *map[string]interface{} `json:"customEvents,omitempty"` EnableQueryRules *bool `json:"enableQueryRules,omitempty"` UseCache *bool `json:"useCache,omitempty"` }
Settings represents the search settings
type SortBy ¶
type SortBy int
func (SortBy) MarshalJSON ¶
MarshalJSON is the implementation of the Marshaler interface for marshaling SortBy type.
func (SortBy) String ¶
String is the implementation of Stringer interface that returns the string representation of SortBy type.
func (*SortBy) UnmarshalJSON ¶
UnmarshalJSON is the implementation of the Unmarshaler interface for unmarshaling SortBy type.