1ee8d5ffc5
This PR introduces the /v1/search/fuzzy API endpoint, used for fuzzy searching objects in Nomad. The fuzzy search endpoint routes requests to the Nomad Server leader, which implements the Search.FuzzySearch RPC method. Requests to the fuzzy search API are based on the api.FuzzySearchRequest object, e.g. { "Text": "ed", "Context": "all" } Responses from the fuzzy search API are based on the api.FuzzySearchResponse object, e.g. { "Index": 27, "KnownLeader": true, "LastContact": 0, "Matches": { "tasks": [ { "ID": "redis", "Scope": [ "default", "example", "cache" ] } ], "evals": [], "deployment": [], "volumes": [], "scaling_policy": [], "images": [ { "ID": "redis:3.2", "Scope": [ "default", "example", "cache", "redis" ] } ] }, "Truncations": { "volumes": false, "scaling_policy": false, "evals": false, "deployment": false } } The API is tunable using the new server.search stanza, e.g. server { search { fuzzy_enabled = true limit_query = 200 limit_results = 1000 min_term_length = 5 } } These values can be increased or decreased, so as to provide more search results or to reduce load on the Nomad Server. The fuzzy search API can be disabled entirely by setting `fuzzy_enabled` to `false`.
34 lines
1.1 KiB
Go
34 lines
1.1 KiB
Go
// Package contexts provides constants used with the Nomad Search API.
|
|
package contexts
|
|
|
|
// Context defines the scope in which a search for Nomad object operates.
|
|
type Context string
|
|
|
|
const (
|
|
// These Context types are used to reference the high level Nomad object
|
|
// types than can be searched.
|
|
Allocs Context = "allocs"
|
|
Deployments Context = "deployment"
|
|
Evals Context = "evals"
|
|
Jobs Context = "jobs"
|
|
Nodes Context = "nodes"
|
|
Namespaces Context = "namespaces"
|
|
Quotas Context = "quotas"
|
|
Recommendations Context = "recommendations"
|
|
ScalingPolicies Context = "scaling_policy"
|
|
Plugins Context = "plugins"
|
|
Volumes Context = "volumes"
|
|
|
|
// These Context types are used to associate a search result from a lower
|
|
// level Nomad object with one of the higher level Context types above.
|
|
Groups Context = "groups"
|
|
Services Context = "services"
|
|
Tasks Context = "tasks"
|
|
Images Context = "images"
|
|
Commands Context = "commands"
|
|
Classes Context = "classes"
|
|
|
|
// Context used to represent the set of all the higher level Context types.
|
|
All Context = "all"
|
|
)
|