25. Key/value lookups#
In addition to timeseries operations, QuasarDB also provides a key/value database under the hood. This chapter shows some examples on how to interact with key/value records directly.
25.1. PUT#
PUT creates a scalar key/value entry. It does not replace an existing
entry. The command returns an error if the key already exists.
PUT stores the entry without an expiration time.
PUT <scalar_type> <key> <value>
scalar_type ::= BLOB | DOUBLE | INT | INT64 | INTEGER | STRING | TIMESTAMP
scalar_typeThe data type of the entry.
INTandINTEGERare aliases forINT64.keyThe name of the entry. Use double quotation marks around a name that contains special characters.
valueThe value to store. The value must be compatible with
scalar_type. PutBLOBandSTRINGvalues in single quotation marks.
Create a blob entry:
PUT BLOB "sensor/config" 'sample every 10 seconds'
Create a 64-bit integer entry:
PUT INT64 "sensor/count" 42
Create a timestamp entry:
PUT TIMESTAMP "sensor/installed_at" 2026-01-15T10:30:00Z
To change an existing key/value entry, use the applicable client API.
25.2. FIND#
FIND selects entries by tag, name, or type. Other query commands can use a
FIND expression instead of an explicit entry name.
FIND (
{
TAG = <tag_value>
| NOT TAG = <tag_value>
| PREFIX = '<prefix>'
| SUFFIX = '<suffix>'
| TYPE = <entry_type>
}
[ AND ... ]
[ , RECURSIVE = { TRUE | FALSE } ]
)
tag_value ::= { '<text>' | $table } [ || ... ]
entry_type ::= {
BLOB | DOUBLE | INT | INT64 | INTEGER | STRING | TIMESTAMP |
DEQUE | HSET | STREAM | TAG | TS
}
TAGSelects entries that have the specified tag. Add
NOTto exclude entries that have the tag.PREFIXSelects entries whose names start with the specified text.
SUFFIXSelects entries whose names end with the specified text.
TYPESelects entries of the specified type.
RECURSIVEAlso searches through tags that match the expression. The default value is
FALSE.$tableUses the current table name in a tag expression. Use
||to join the table name and text.
25.3. Examples#
Find all key/value entries that have the tag “stocks”:
FIND(tag='stocks')
Find all timeseries that have the tag “stocks”:
FIND(tag='stocks' AND type=ts)
Find all entries that have the tags “stocks”, “euro”, “industry”:
FIND(tag='stocks' AND tag='euro' AND tag='industry')
Find all entries that have the tags “stocks”, “euro”, “industry” but not “germany”:
FIND(tag='stocks' AND tag='euro' AND tag='industry' AND NOT tag='germany')
Find all entries that have the tags “stocks”, “euro”, “industry” but not “germany”, and are a time series:
FIND(tag='stocks' AND tag='euro' AND tag='industry' AND NOT tag='germany' AND type=ts)
Find all entries that have the tag “stocks”, then for each tag <Y> found add the results from FIND(tag='<Y>', RECURSIVE=TRUE):
FIND(tag='stocks', RECURSIVE=TRUE)
Find all entries whose names start with market/:
FIND(PREFIX='market/')
Find all entries whose names end with /trades:
FIND(SUFFIX='/trades')
Find all string entries:
FIND(TYPE=STRING)
Find tables whose tag contains the table name:
FIND(TAG='source/' || $table)
To add, remove, or list tags, refer to tag commands.