Object Metadata Querying
Tigris indexes important metadata fields such as Content-Type
,
Content-Length
, and Last-Modified
for every object stored in a bucket. You
can query these objects using a SQL-like syntax through the X-Tigris-Query
header when using the
ListObjectsV2 API.
The X-Tigris-Query
field query can be thought of as the WHERE
clause in a
SQL query. For instance, to find all objects with a Content-Type
of
text/javascript
, set the header as follows:
X-Tigris-Query
:WHERE `Content-Type` = "text/javascript"
Queryable Fields
Tigris supports querying against the following fields:
`Content-Type`
: The content type assigned during upload.`Content-Length`
: The size of the object.`Last-Modified`
: The date and time the object was last modified in RFC3339 format.`key`
: The key of the object.`Event-Type`
: The type of the event, this is only supported in Object Notifications.
SQL Operations
Query supports following comparison operators:
=
: Equal!=
: Not Equal>
and<
: Greater than and less than>=
and<=
: Greater than or equal and less than or equalAND
: Combine multiple conditions in a query.
In Memory Operations
Tigris supports IN
, NOT IN
, and REGEXP
operators for filtering results.
Since these operations are performed in memory, they must be combined with SQL
operations mentioned above. For example:
WHERE `Content-Type` = "text/plain" AND key REGEXP ".*\.txt$"
WHERE `Content-Length` > 1024 AND `Content-Type` IN ("text/javascript", "text/css")
.WHERE `Content-Length` != 65536 AND `Content-Type` NOT IN ("text/plain", "text/html")
.
Order by
You can sort the list using ORDER BY
. For example, to retrieve all items
smaller than 64KB
ordered by Content-Type
:
`Content-Length` < 65536 ORDER BY `Content-Type`
Example Queries
Example queries that can be performed:
WHERE `Content-Type` = "text/plain"
WHERE `Content-Type` >= "text/c" AND `Content-Type` < "text/j"
WHERE `Content-Length` > 0 ORDER BY `Content-Length` ASC
WHERE `Content-Length` != 65536 AND `Content-Type` = "text/plain"
WHERE `Last-Modified` > "2024-06-23T10:38:46Z"
Next steps
- Check out the Example usage for more details on how to use them in your application.