Skip to content

Commit

Permalink
Docs: correct search API (#7756)
Browse files Browse the repository at this point in the history
This closes #7718. It corrects some inaccuracies and adds
an explanation of the truncations block.
  • Loading branch information
backspace authored Apr 21, 2020
1 parent 9f5156a commit dd2e387
Showing 1 changed file with 31 additions and 20 deletions.
51 changes: 31 additions & 20 deletions website/pages/api-docs/search.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ description: The /search endpoint is used to search for Nomad objects
# Search HTTP API

The `/search` endpoint returns matches for a given prefix and context, where a
context can be jobs, allocations, evaluations, nodes, or deployments. When using
Nomad Enterprise, the allowed contexts include quotas and namespaces.
Additionally, a prefix can be searched for within every context.
context can be jobs, allocations, evaluations, nodes, deployments, plugins,
or volumes. When using Nomad Enterprise, the allowed contexts include quotas
and namespaces. Additionally, a prefix can be searched for within every context.

| Method | Path | Produces |
| ------ | ------------ | ------------------ |
Expand All @@ -36,14 +36,15 @@ job related results will not be returned. If the token is only valid for
matches might be "abcd", or "aabb".
- `Context` `(string: <required>)` - Defines the scope in which a search for a
prefix operates. Contexts can be: "jobs", "evals", "allocs", "nodes",
"deployment" or "all", where "all" means every context will be searched.
"deployment", "plugins", "volumes" or "all", where "all" means every
context will be searched.

### Sample Payload (for a specific context)
### Sample Payload (for all contexts)

```javascript
{
"Prefix": "abc",
"Context": "evals"
"Context": "all"
}
```

Expand All @@ -61,20 +62,38 @@ $ curl \
```json
{
"Matches": {
"evals": ["abc2fdc0-e1fd-2536-67d8-43af8ca798ac"]
"allocs": null,
"deployment": null,
"evals": ["abc2fdc0-e1fd-2536-67d8-43af8ca798ac"],
"jobs": ["abcde"],
"nodes": null,
"plugins": null,
"volumes": null
},
"Truncations": {
"evals": "false"
"allocs": "false",
"deployment": "false",
"evals": "false",
"jobs": "false",
"nodes": "false",
"plugins": "false",
"volumes": "false"
}
}
```

### Sample Payload (for all contexts)
#### Field Reference

- `Matches` - A map of contexts to matching arrays of identifiers.

- `Truncations` - Search results are capped at 20; if more matches were found for a particular context, it will be `true`.

### Sample Payload (for a specific context)

```javascript
{
"Prefix": "abc",
"Context": ""
"Context": "evals"
}
```

Expand All @@ -92,18 +111,10 @@ $ curl \
```json
{
"Matches": {
"allocs": [],
"deployment": [],
"evals": ["abc2fdc0-e1fd-2536-67d8-43af8ca798ac"],
"jobs": ["abcde"],
"nodes": []
"evals": ["abc2fdc0-e1fd-2536-67d8-43af8ca798ac"]
},
"Truncations": {
"allocs": "false",
"deployment": "false",
"evals": "false",
"jobs": "false",
"nodes": "false"
"evals": "false"
}
}
```

0 comments on commit dd2e387

Please sign in to comment.