Filters#
- class relevanceai.utils.filters.Filter#
Filters have been designed to become more pythonic.
old filters = [ { "field": "product_name", "filter_type": "exact_match", "condition": "==", "condition_value": "Durian Leather 2 Seater Sofa" } ] new_filters = dataset["product_name"] == "Durian Leather 2 Seater Sofa" # Produces the same as above older_filters = [ { "field": "rank", "filter_type": "numeric", "condition": ">=", "condition_value": 2 }, { "field": "rank", "filter_type": "numeric", "condition": "<", "condition_value": 3 } ] new_filters = (dataset["rank"] >= 2) + (dataset["rank"] < 3)
Exists filtering can be accessed in a simple way.
old_filters = [ { "field": "brand", "filter_type": "exists", "condition": "==", "condition_value": " " } ] new_filters = dataset["brand"].exists() old_filters = [ { "field": "brand", "filter_type": "exists", "condition": "!=", "condition_value": " " } ] new_filters = dataset["brand"].not_exists()
Same with contains.
old_filters = [ { "field": "description", "filter_type": "contains", "condition": "==", "condition_value": "Durian BID" } ] new_filters = dataset["description"].contains("Durian BID")
Date filtering
old_filters = [ { "field": ""insert_date_"", "filter_type": "date", "condition": "==", "condition_value": "2020-07-01" } ] new_filters = dataset["_insert_date"].date(2020-07-01")