Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions docs/guides/work-with-units.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,23 @@ for u in api.units.list().await?.get_items() {

## Tag a series with a unit

A series carries two unit fields. `unit` is required free text of at most 64 characters, the
label a chart shows (`bar`, `掳C`); it is never checked against the catalogue. `unitExternalId`
is optional and is the catalogue key (`pressure_bar`); set it when a consumer should be able to
resolve the unit's symbol, quantity and conversion. The unit leaves the value type alone (the Python
and Rust examples set `float`); it describes what the numbers mean.
A series carries two unit fields. `unit` is free text of at most 64 characters, the label a
chart shows (`bar`, `掳C`). `unitExternalId` is the catalogue key (`pressure_bar`); set it when a
consumer should be able to resolve the unit's symbol, quantity and conversion. A create needs at
least one of them:

| You send | Result |
| --- | --- |
| `unitExternalId` only | Accepted if the catalogue has it; `unit` is filled from the entry's symbol (its name if it has no symbol). |
| `unit` and `unitExternalId` | Both kept as sent, as long as the catalogue has the `unitExternalId`. |
| `unit` only | Accepted as is; the catalogue is not consulted. |
| A blank `unitExternalId`, or one the catalogue does not have | `400`, with a field error on `unitExternalId`, whether or not `unit` is set. |
| Neither | `400`. |

The lookup normalises the id to lower snake_case first, so `Temperature_Deg_C` finds
`temperature_deg_c`. An update that sets `unitExternalId` is checked the same way before
anything is written; clearing it with `setNull` is still allowed. The unit leaves the value type
alone (the Python and Rust examples set `float`); it describes what the numbers mean.

<Tabs groupId="lang">
<TabItem value="java" label="Java">
Expand Down
2 changes: 1 addition & 1 deletion docs/mcp-server.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ neighbour ("the time series measuring this pump").
| `timeseries_list` | Browse when you do not yet have a search term |
| `timeseries_search` | Full-text search over name, externalId and description, ranked by relevance |
| `timeseries_get` | Look up by externalId or numeric id |
| `timeseries_create` | Create one time series, returns the assigned id. Needs a `unit` or a `unitExternalId` (see `unit_list`) |
| `timeseries_create` | Create one time series, returns the assigned id. Needs a `unit` or a `unitExternalId`; a `unitExternalId` must be in the catalogue (see `unit_list`) |
| `timeseries_update` | Update common fields by id |
| `timeseries_delete` | Delete the definition. Existing datapoints are not removed |
| `timeseries_get_latest` | Most recent datapoint, for "what is it reading now?" |
Expand Down
9 changes: 8 additions & 1 deletion docs/reference/timeseries.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ api.time_series.create_one(&ts).await?;
</TabItem>
</Tabs>

A create needs a `unit` (free text), a `unitExternalId` from the [unit catalogue](./units), or
both. Given only `unitExternalId`, the series gets its `unit` from the catalogue entry; a
`unitExternalId` the catalogue does not have is a `400` on that field.
[Tag a series with a unit 鈫抅(../guides/work-with-units#tag-a-series-with-a-unit)

## Value types

Every series has a **value type** that decides how its datapoints are stored. A create that
Expand Down Expand Up @@ -369,7 +374,9 @@ set and everything beneath it in the `BELONGS_TO` hierarchy. Anything narrower b
`POST /timeseries/update` changes fields on series that already exist. It is a partial update:
only the fields named in each entry's `update` block change, and the series is identified by
`id` or `externalId`. Changing `valueType` on a series that already holds data is refused,
because the stored points would no longer parse; create a new series instead.
because the stored points would no longer parse; create a new series instead. Setting
`unitExternalId` to a blank value or one the [unit catalogue](./units) does not have is a `400`
on `unitExternalId`, before anything is written; `setNull` still clears it.

```java
import ai.intellistream.datahub.timeseries.UpdateTimeseries;
Expand Down
Loading