Create a timestamp filter for date/time-based searches.
This is a convenience function that provides a fluent API for building timestamp filters. Timestamp filters work with Date objects or Unix epoch timestamps and support range queries.
Important: Timestamps are stored as NUMERIC fields in Redis (Unix epoch timestamps).
When defining your schema, use type: "numeric" for timestamp fields.
Timestamp(field: string): __type| Name | Type | Description |
|---|---|---|
field* | string | The name of the numeric field containing timestamp data |
// Define schema with numeric type for timestamps
const schema: MetadataFieldSchema[] = [
{ name: "created_at", type: "numeric", options: { sortable: true } }
];
// Filter by date
const filter = Timestamp("created_at").gt(new Date("2023-01-01"));
// Date range
const filter = Timestamp("created_at").between(
new Date("2023-01-01"),
new Date("2023-12-31")
);
// Using epoch timestamps
const filter = Timestamp("updated_at").gte(1672531200);
// Combine with other filters
const complexFilter = Timestamp("created_at").gt(new Date("2023-01-01"))
.and(Tag("status").eq("published"));