Applying Filters to Queries

The filtering functionality allows you to apply filters to a dataset based on specific criteria. This documentation provides an overview of the filtering functionality and how to use it effectively.

 

Introduction

The filtering functionality provides a way to retrieve specific data from a dataset by applying filters to the dataset’s fields. Filters are created using a combination of operators and values to define the criteria for filtering.

 

Filter Operators

The filtering functionality supports several filter operators that can be used to define different types of criteria. These operators are used in combination with the field name and the desired value to create a filter.

The following filter operators are available:

  • eq (Equals): Matches records where the field value is equal to the specified value.
  • neq (Not Equals): Matches records where the field value is not equal to the specified value.
  • gt (Greater Than): Matches records where the field value is greater than the specified value.
  • gte (Greater Than or Equal To): Matches records where the field value is greater than or equal to the specified value.
  • lt (Less Than): Matches records where the field value is less than the specified value.
  • lte (Less Than or Equal To): Matches records where the field value is less than or equal to the specified value.
  • contains: Matches records where the field value contains the specified value.
  • ncontains: Matches records where the field value does not contain the specified value.

 

Filter Syntax

To apply filters to a dataset, you need to specify the filters in the URL query parameters. The syntax for specifying filters in the URL is as follows:

https://connectors.windsor.ai/connector_name?api_key&fields=[fields]&filter=[field_name]_$[operator].[value]

In the above syntax:

  • field_name is the name of the field on which the filter should be applied.
  • operator is one of the filter operators mentioned earlier.
  • value is the value used to filter the field.

Multiple filters can be combined using logical operators ($and, $or, $not) to create complex filter expressions. The logical operators are placed between the filters in the URL.

 

Sample URL

As an example, consider the following sample URL:

https://connectors.windsor.ai/google_ads?api_key=abcd&fields=adnetwork_conversions,adnetwork_revenue,campaign,campaign_id,clicks,date,impressions,interactions,spend,source,ad_group&filter=ad_group_$contains.138361309668*$and*$campaign_id_$eq.15272819724*$and*$impressions_$gte.32

In the above URL:

  • fields parameter specifies the fields that should be included in the response.
  • ad_group_$contains.138361309668 specifies a filter that matches records where the ad_group field contains the value 138361309668.
  • $and is the logical operator used to combine multiple filters.
  • campaign_id_$eq.15272819724 specifies a filter that matches records where the campaign_id field is equal to 15272819724.
  • $and is used again to combine the previous filter with the next filter.
  • impressions_$gte.32 specifies a filter that matches records where the impressions field is greater than or equal to 32.

The above URL demonstrates how to combine multiple filters using the $and operator to create a complex filter expression. It also includes the fields parameter to specify which fields should be included in the response.

 

Conclusion

The filtering functionality provides a powerful way to retrieve specific data from a dataset by applying filters based on different criteria. By using the supported filter operators and combining them with logical operators, you can create complex filter expressions to precisely retrieve the data you need.