@@ -45,34 +45,66 @@ specified date.
4545
4646` filter ` metadata filtering \
4747Select datasets matching the metadata expressions specified via ` filter `
48- query parameters. Each expression is the name of a metadata key (for example,
49- ` dataset.name ` ), followed by a colon (` : ` ) and the comparison string. The
50- comparison string may be prefixed with a tilde (` ~ ` ) to make it a partial
51- ("contains") comparison instead of an exact match. For example,
52- ` dataset.name:foo ` looks for datasets with the name "foo" exactly, whereas
53- ` dataset.name:~foo ` looks for datasets with a name containing the substring
54- "foo".
55-
56- These may be combined across multiple ` filter ` query parameters or as
57- comma-separated lists in a single query parameter. Multiple filter expressions
58- form an ` AND ` expression, however consecutive filter expressions can be joined
59- in an ` OR ` expression by using the circumflex (` ^ ` ) character prior to each.
60- (The first expression with ` ^ ` begins an ` OR ` list while the first subsequent
61- expression outout ` ^ ` ends the ` OR ` list and is combined with an ` AND ` .)
48+ query parameters. Each expression has the format ` [chain]key:[op]value[:type] ` :
49+
50+ * ` chain ` Prefix an expression with ` ^ ` (circumflex) to allow combining a set
51+ of expressions with ` OR ` rather than the default ` AND ` .
52+ * ` key ` The name of a metadata key (for example, ` dataset.name ` )
53+
54+ * ` op ` An operator to specify how to compare the key value:
55+
56+ * ` = ` (Default) Compare for equality
57+ * ` ~ ` Compare against a substring
58+ * ` > ` Greater than
59+ * ` < ` Less than
60+ * ` >= ` Greater than or equal to
61+ * ` <= ` Less than or equal to
62+ * ` != ` Not equal
63+
64+ * ` value ` The value to compare against. This will be interpreted based on the specified type.
65+ * ` type ` The string value will be cast to this type. Any value can be cast to
66+ type ` str ` . General metadata keys (` server ` , ` global ` , ` user ` , and
67+ ` dataset.metalog ` namespaces) that have values incompatible with the specified
68+ type will be ignored. If you specify an incompatible type for a primary
69+ ` dataset ` key, an error will be returned as these types are defined by the
70+ Pbench schema so no match would be possible. (For example, ` dataset.name:2:int `
71+ or ` dataset.access:2023-05-01:date ` .)
72+
73+ * ` str ` (Default) Compare as a string
74+ * ` bool ` Compare as a boolean
75+ * ` int ` Compare as an integer
76+ * ` date ` Compare as a date-time string. ISO-8601 recommended, and UTC is
77+ assumed if no timezone is specified.
78+
79+ For example, ` dataset.name:foo ` looks for datasets with the name "foo" exactly,
80+ whereas ` dataset.name:~foo ` looks for datasets with a name containing the
81+ substring "foo".
82+
83+ Multiple expressions may be combined across multiple ` filter ` query parameters
84+ or as comma-separated lists in a single query parameter. Multiple filter
85+ expressions are combined as an ` AND ` expression, matching only when all
86+ expressions match. However any consecutive set of expressions starting with ` ^ `
87+ are collected into an "` OR ` list" that will be ` AND ` -ed with the surrounding
88+ terms.
6289
6390For example,
6491- ` filter=dataset.name:a,server.origin:EC2 ` returns datasets with a name of
6592"a" and an origin of "EC2".
66- - ` filter=dataset.name:a,^server.origin:EC2,^dataset.metalog.pbench.script:fio `
67- returns datasets with a name of "a" and * either* an origin of "EC2" or generated
68- from the "pbench-fio" script.
69-
70- _ NOTE_ : ` filter ` expression values, like the ` true ` in
71- ` GET /api/v1/datasets?filter=server.archiveonly:true ` , are always interpreted
72- as strings, so be careful about the string representation of the value (in this
73- case, a boolean, which is represented in JSON as ` true ` or ` false ` ). Beware
74- especially when attempting to match a JSON document (such as
75- ` dataset.metalog.pbench ` ).
93+ - `filter=dataset.name:~ andy,^server.origin: EC2 ,^server.origin: RIYA ,
94+ dataset.access: public `
95+ returns only "public" datasets with a name containing the string "andy" which also
96+ have an origin of either "EC2" or "RIYA". As a SQL query, we might write it
97+ as `dataset.name like "%andy%" and (server.origin = 'EC2' or
98+ server.origin = 'RIYA') and dataset.access = 'public'`.
99+
100+ _ NOTE_ : ` filter ` expression term values, like the ` true ` in
101+ ` GET /api/v1/datasets?filter=server.archiveonly:true ` , are by default
102+ interpreted as strings, so be careful about the string representation of the
103+ value. In this case, ` server.archiveonly ` is a boolean, which will be matched
104+ as a string value "true" or "false". You can instead specify the expression
105+ term as ` server.archiveonly:t:bool ` which will treat the specified match value
106+ as a boolean (` t[rue] ` or ` y[es] ` for true, ` f[alse] ` or ` n[o] ` for false) and
107+ match against the boolean metadata value.
76108
77109` keysummary ` boolean \
78110Instead of displaying a list of selected datasets and metadata, use the set of
@@ -105,6 +137,10 @@ Allows filtering for datasets owned by the authenticated client (if the value
105137is omitted, e.g., ` ?mine ` or ` ?mine=true ` ) or owned by * other* users (e.g.,
106138` ?mine=false ` ).
107139
140+ ` name ` string \
141+ Select only datasets with a specified substring in their name. The filter
142+ ` ?name=fio ` is semantically equivalent to ` ?filter=dataset.name:~fio ` .
143+
108144` offset ` integer \
109145"Paginate" the selected datasets by skipping the first ` offset ` datasets that
110146would have been selected by the other query terms. This can be used with
0 commit comments