Querying Resources
Querying resources happens
in
the /list
endpoint of the resource controller.
Example 1: Basic OQS Query
This example demonstrates a basic OQS query, which is equivalent to the previous selector query:
{
"#EQUALS": [
"$kind",
"catalog.hubocean.io/dataset"
]
}
In this query, the '#EQUALS' key acts as an operator. The value of the '#EQUALS' key should be a list containing a reference (using the dollar sign) and the desired value. The query searches for data where the referenced field ('$kind') is equal to the specified value.
Example 2: OQS Query with the '"#WITHIN"' Operator
The #WITHIN operator allows you to specify multiple possible values for a field. Here's an example:
{
"#WITHIN": [
"$kind",
[
"catalog.hubocean.io/dataset",
"catalog.hubocean.io/observable"
]
]
}
This query searches for data where the 'kind' field matches either '"catalog.hubocean.io/dataset"' or '"catalog.hubocean.io/observables"'.
Example 3: OQS Query with Multiple Conditions
You can combine multiple conditions using the '#AND' operator. Here's an example:
{
"#AND": [
{
"#WITHIN": [
"$kind",
[
"catalog.hubocean.io/dataset",
"catalog.hubocean.io/observable"
]
]
},
{
"#EQUALS": [
"$metadata.name",
"test-dataset"
]
}
]
}
This query searches for data that satisfies both conditions: the 'kind' field must match either '"catalog.hubocean.io/dataset"' or '"catalog.hubocean.io/observables,"' and the 'metadata.name' field must be equal to '"test-dataset"'.
Example 4: Referencing Nested Values
To reference a nested value, such as '"metadata.labels.hubocean.io/nodelete"', you can use the following syntax:
{
"#IS_NULL": [
"$metadata.labels.'hubocean.io/nodelete'"
]
}
This query checks if the value of '"metadata.labels.hubocean.io/nodelete"' is null.
Range Queries
Range queries allow you to search for data within a specific range. Unfortunately, we don't have an example of range queries in the provided information. However, please consult our additional documentation or reach out to our support team for assistance with range queries.
Here's an example of performing a range query using OQS:
{
"#AND": [
{
"#GREATER_THAN_OR_EQUALS": [
"$status.created_time",
"2023-05-31T15:19:40"
]
},
{
"#LESS_THAN_OR_EQUALS": [
"$status.created_time",
"2023-05-31T15:19:50"
]
}
]
}
In this query, we use the '#AND' operator to combine two conditions. The first condition, '#GREATER_THAN_OR_EQUALS', checks if the value of '$status.created_time' is greater than or equal to '2023-05-31T15:19:40'. The second condition, '#LESS_THAN_OR_EQUALS', checks if the value of '$status.created_time' is less than or equal to '2023-05-31T15:19:50'. By using these operators, you can perform range queries based on specific date and time values.
Check out our reference for more information on how to use query with OQS here.