Search
Generated at build time from packages/core/src/operations/search.ts. Every operation below isPOST /v1/ops/{name} over HTTP, env.API.invoke(actor, name, input) over RPC, and, when staff may call it, an MCP tool. See the API overview for authentication and errors.
search.query
Search everything
One search across accounts, contacts, sites, machines (by serial number), orders, tickets, parts, parts orders and documents. Matches prefixes, so 'M300-24' finds serial M300-2417. Returns the best matches with the record type, a title, a snippet and the path of the record in the web app.
Input (object)
| Field | Type | Description |
|---|---|---|
queryrequired | string | min length 1, max length 200 |
types | ("account" | "contact" | "site" | "machine" | "order" | "ticket" | "part" | "parts_order" | "document")[] | Limit to these record types |
limit | integer | default 20, min 1, max 50 |
Output (object)
| Field | Type | Description |
|---|---|---|
queryrequired | string | |
resultsrequired | object[] | |
entityTyperequired | "account" | "contact" | "site" | "machine" | "order" | "ticket" | "part" | "parts_order" | "document" | |
entityIdrequired | string | Record id (UUID)min length 1, max length 64 |
titlerequired | string | |
subtitlerequired | string | null | |
snippetrequired | string | null | Matching text with the hit wrapped in <mark> tags |
accountIdrequired | string | null | Record id (UUID)min length 1, max length 64 |
pathrequired | string | Path of the record in the web app, for example /orders/{id} |
countsrequired | record of integer | Number of results per record type |
Example request
curl https://api.cemco.app/v1/ops/search.query \
-H "x-api-key: $CEMCO_API_KEY" \
-H "content-type: application/json" \
-d '{"query":"example"}'
JSON Schema
{
"input": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"query": {
"type": "string",
"minLength": 1,
"maxLength": 200
},
"types": {
"description": "Limit to these record types",
"type": "array",
"items": {
"type": "string",
"enum": [
"account",
"contact",
"site",
"machine",
"order",
"ticket",
"part",
"parts_order",
"document"
]
}
},
"limit": {
"default": 20,
"type": "integer",
"minimum": 1,
"maximum": 50
}
},
"required": [
"query"
]
},
"output": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"query": {
"type": "string"
},
"results": {
"type": "array",
"items": {
"type": "object",
"properties": {
"entityType": {
"type": "string",
"enum": [
"account",
"contact",
"site",
"machine",
"order",
"ticket",
"part",
"parts_order",
"document"
]
},
"entityId": {
"type": "string",
"minLength": 1,
"maxLength": 64,
"description": "Record id (UUID)"
},
"title": {
"type": "string"
},
"subtitle": {
"type": [
"string",
"null"
]
},
"snippet": {
"description": "Matching text with the hit wrapped in <mark> tags",
"type": [
"string",
"null"
]
},
"accountId": {
"anyOf": [
{
"type": "string",
"minLength": 1,
"maxLength": 64,
"description": "Record id (UUID)"
},
{
"type": "null"
}
]
},
"path": {
"type": "string",
"description": "Path of the record in the web app, for example /orders/{id}"
}
},
"required": [
"entityType",
"entityId",
"title",
"subtitle",
"snippet",
"accountId",
"path"
],
"additionalProperties": false
}
},
"counts": {
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"description": "Number of results per record type"
}
},
"required": [
"query",
"results",
"counts"
],
"additionalProperties": false
}
}
search.reindex
Rebuild the search index
Rebuild the full-text search index from the tables. Run after a bulk import or if search results look out of date.
Input (object)
| Field | Type | Description |
|---|---|---|
types | ("account" | "contact" | "site" | "machine" | "order" | "ticket" | "part" | "parts_order" | "document")[] | Only these record types; all when omitted |
Output (object)
| Field | Type | Description |
|---|---|---|
indexedrequired | integer | min -9007199254740991, max 9007199254740991 |
byTyperequired | record of integer |
Example request
curl https://api.cemco.app/v1/ops/search.reindex \
-H "x-api-key: $CEMCO_API_KEY" \
-H "content-type: application/json" \
-d '{}'
JSON Schema
{
"input": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"types": {
"description": "Only these record types; all when omitted",
"type": "array",
"items": {
"type": "string",
"enum": [
"account",
"contact",
"site",
"machine",
"order",
"ticket",
"part",
"parts_order",
"document"
]
}
}
}
},
"output": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"indexed": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"byType": {
"type": "object",
"propertyNames": {
"type": "string"
},
"additionalProperties": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
}
}
},
"required": [
"indexed",
"byType"
],
"additionalProperties": false
}
}