Knowledge Base Article

Filter results on a specific date range with dates converted to Unix timestamps.

According to the Vertex AI document, it seems that the dynamic facet option only supports the types: number, String, Boolean, and Integer. But we are getting the Data type as DateTime.

Unfortunately the Vertex Search filtering functionality is pretty limited at the moment.

Here is the documentation for how to implement filtering using the API. You'll notice there is no built-in support for date filtering currently, but there is support for filtering on numerical fields.

Workaround:

One workaround I can think of right now is to ingest documents with their dates converted to Unix timestamps (integers). In the front-end of the application you could provide a normal date picker to provide a date range, and then in the backend convert this to unix time and perform numerical filtering.

Example: "Jan 12 2023 to Jan 12 2024" would be equivalent to a unix time filter of between 1673481600 and 1705017600.

In Vertex Search this would be applied as a filter in the syntax: date_field_name: IN (1673481600, 1705017600)

Updated 6 months ago
Version 2.0
No CommentsBe the first to comment