hashicorp / nomad

Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications. Nomad is easy to operate and scale and has native Consul and Vault integrations.
https://www.nomadproject.io/
Other
14.64k stars 1.93k forks source link

api: fuzzy search min_term_length configuration seems to have no effect #10588

Open backspace opened 3 years ago

backspace commented 3 years ago

Nomad version

Nomad v1.1.0-rc1 (c16a2850549eae74a0bfab5aad359b3c6926280f)

Operating system and Environment details

macOS 10.14.6

~/Downloads/nomad-110-rc1 agent -dev -config=server-longer-minimum-search-and-enabled.hcl

Issue

With the following server configuration (the seemingly-redundant fuzzy_enabled is due to #10587):

server {
  search {
    fuzzy_enabled = true
    min_search_length = 3
  }
}

When querying with a too-short search string, it still appears to search, or at least returns the results structure:

curl 'http://localhost:4646/v1/search/fuzzy' --data-raw '{"Text":"x","Context":"all"}'

{"Matches":{"evals":[],"deployment":[],"volumes":[],"scaling_policy":[]},"Truncations":{"evals":false,"volumes":false,"scaling_policy":false,"jobs":false,"nodes":false,"plugins":false,"deployment":false,"allocs":false,"namespaces":false},"Index":9,"LastContact":0,"KnownLeader":true}

Whereas running with no server configuration, a too-short query returns an error that specifies the minimum length:

curl 'http://localhost:4646/v1/search/fuzzy' --data-raw '{"Text":"x","Context":"all"}'

fuzzy search query must be at least 2 characters, got 1
backspace commented 3 years ago

maybe it never returns any results when the minimum length is configured? I’m getting nothing back when I’d expect something, with a proper-length query.