Documentation
¶
Index ¶
- Constants
- Variables
- func FormatResponse(resp *meta.SearchResponse, q *meta.ZedQuery, buckets *search.Bucket) error
- func MatchQueryRules(ruleset *meta.QueryRuleset, criteria map[string]interface{}) []*meta.QueryRule
- func ParseQueryDSL(q *meta.ZedQuery, mappings *meta.Mappings, ...) (riot.SearchRequest, error)
- func ParseQueryDSLFromV1(q *v1.ZedQuery) (*meta.ZedQuery, error)
- func RescoreWindow(rescorers []*Rescorer, from, size int) int
- func Rewrite(query interface{}, ...) (interface{}, error)
- func RewriteLimit() int
- func RuleQuery(body map[string]interface{}, lookup RulesetLookup) (map[string]interface{}, error)
- func SortQueryRules(rules []*meta.QueryRule)
- func Transform(query interface{}, fns map[string]TransformFunc) (interface{}, error)
- func ValidateQueryRule(rule *meta.QueryRule) error
- type ExecFunc
- type Rescorer
- type RulesetLookup
- type TransformFunc
Constants ¶
const DefaultRescoreWindow = 10
DefaultRescoreWindow is the Elasticsearch default window_size.
const MaxRewriteMatches = 65536
MaxRewriteMatches is hard limit of documents joined by single nested / has_child / has_parent clause.
Variables ¶
var ( QueryRuleTypes = []string{"pinned", "exclude"} QueryRuleCriteriaTypes = []string{"exact", "fuzzy", "prefix", "suffix", "contains", "lt", "lte", "gt", "gte", "always"} )
QueryRuleTypes and QueryRuleCriteriaTypes are the values the query rules API accepts.
Functions ¶
func FormatResponse ¶
func MatchQueryRules ¶ added in v1.4.0
func MatchQueryRules(ruleset *meta.QueryRuleset, criteria map[string]interface{}) []*meta.QueryRule
MatchQueryRules returns the rules of ruleset whose criteria all match.
func ParseQueryDSL ¶
func ParseQueryDSL(q *meta.ZedQuery, mappings *meta.Mappings, analyzers map[string]*analysis.Analyzer) (riot.SearchRequest, error)
ParseQueryDSL parse query DSL and return searchRequest
func ParseQueryDSLFromV1 ¶
ParseQueryDSLFromV1 parse query DSL from search v1 and return new zed query DSL
func RescoreWindow ¶ added in v1.4.0
RescoreWindow is the number of top hits a search has to collect so that every rescorer sees its whole window and the requested page.
func Rewrite ¶
func Rewrite(query interface{}, exec func(sub map[string]interface{}, collectField string) ([]string, error)) (interface{}, error)
Rewrite replaces `nested`, `has_child`, `has_parent` and `parent_id` clauses of query DSL by plain term queries on hidden fields. Riot has no block join support, so joins are resolved in separate search pass (exec) and result is pushed back into query as list of document ids.
Clauses are rewritten as:
nested{path,query} -> terms _id of matching _nested_parent
has_child{type,query} -> terms _id of matching _join_parent
has_parent{type,query} -> terms _join_parent of matching _id
parent_id{type,id} -> _join_name + _join_parent terms
`score_mode` / `score` are accepted but ignored: joined documents get constant score, child scores are not propagated to parent.
func RewriteLimit ¶
func RewriteLimit() int
RewriteLimit returns maximum number of documents single join clause may match.
func RuleQuery ¶ added in v1.4.0
func RuleQuery(body map[string]interface{}, lookup RulesetLookup) (map[string]interface{}, error)
RuleQuery rewrites the body of a rule query into the query DSL applying the matched rules: pinned documents promote over organic, excluded documents are removed from all results.
func SortQueryRules ¶ added in v1.4.0
SortQueryRules orders rules by priority, rules without priority last, and keeps the stored order of equal priorities.
func Transform ¶ added in v1.4.0
func Transform(query interface{}, fns map[string]TransformFunc) (interface{}, error)
Transform walks query and replaces every clause named in fns, at any depth of compound queries, by the query its function returns.
func ValidateQueryRule ¶ added in v1.4.0
ValidateQueryRule checks a rule of the query rules API.
Types ¶
type ExecFunc ¶
ExecFunc runs sub query and returns value of collectField for every matching document. Values are returned one per match, duplicates included, so that callers can count matches per parent (has_child min_children/max_children).
type Rescorer ¶ added in v1.4.0
type Rescorer struct {
WindowSize int
Query map[string]interface{}
QueryWeight float64
RescoreQueryWeight float64
ScoreMode string // total, multiply, avg, max, min
}
Rescorer is one query rescorer of the rescore section of a search.
func ParseRescore ¶ added in v1.4.0
ParseRescore parses a rescorer object or an array of them.
type RulesetLookup ¶ added in v1.4.0
type RulesetLookup func(id string) (*meta.QueryRuleset, error)
RulesetLookup loads a ruleset by id.
type TransformFunc ¶ added in v1.4.0
TransformFunc replaces the body of a query clause by a new query.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal/testutil
Package testutil holds helpers shared by the analysis test packages.
|
Package testutil holds helpers shared by the analysis test packages. |
|
Package assoc implements the Elasticsearch "associated terms" features (more_like_this, suggesters, significant_terms) as pure functions over riot readers.
|
Package assoc implements the Elasticsearch "associated terms" features (more_like_this, suggesters, significant_terms) as pure functions over riot readers. |