Filtering documents which were added to the database after January 2021.Filtering documents which were added to the database after January 2021.

Filtering documents which were added to the database after January 2021.

date

This filter performs date analysis and filters documents based on their date information. For instance, it is possible to filter out any documents with a production date before January 2021.

from relevanceai import Client 
client = Client()

filter =  [{'field' : 'insert_date_',    # field to look at
            'filter_type' : 'date', 
            "condition":">=", 
            "condition_value":"2021-01-01"}] # searching for production date after 2020-01-01
filtered_data = client.datasets.documents.get_where(dataset_id, filter)

Note that the default format is "yyyy-mm-dd" but can be changed to "yyyy-dd-mm" through the format parameter as shown in the example below.

client = Client(project, api_key)

filter =  [{'field' : 'insert_date_',  # field to look at
            'filter_type' : 'date', 
            "condition":">=", 
            "condition_value": "2020-15-05", # searching for production date after May 15th 
            "format":"yyyy-dd-MM"
           }] 
filtered_data = client.datasets.documents.get_where(dataset_id, filter)

Did this page help you?