What is BrewwQL?

We designed BrewwQL to help users simply and powerfully filter their data in Breww.

With a few simple operators, you can now easily create simple or complex filters to drill down deeper and more easily into your Breww data.


Examples

Basic examples

To best understand BrewwQL, it's helpful to see some simple examples.

Let's say we wanted to see all of our customers whose delivery address was in London. In the customer filter form, we would type:

delivery_address_city = "London"

And that's it. The autocomplete will show every option as you go, making it really straightforward to put together queries and view available options.

If we want to drill down deeper, we can. From those customers, maybe we only want to see those whose average order value is greater than £250. For this we would chain two statements together with the and operator.

delivery_address_city = "London" and average_order_value > 250

Perhaps we are wondering which of those customers have lapsed, as we might want to contact them about reordering. So let's narrow the search for only customers who haven't ordered in the last 90 days.

delivery_address_city = "London" and average_order_value > 250 and last_order_date < "90 days ago"

Now let's say we are doing some admin, and we wanted to see all customers who we haven't entered a contact for yet. In the customer filter box, we would type:

contacts = None

Advanced examples

BrewwQL allows us to traverse through attributes of what we are searching through. For example if we wanted to see customers who are part of a customer group with a billing address in London we would write:

customer_group.invoice_address_city = "London"

The . between 'customer_group' and 'invoice_address_city' is used in BrewwQL as a way of traversing through attributes of attributes.

We can also use brackets to add more complexity to our searches.

(delivery_address_city = "London" or average_order_value > 250) and last_order_date < "90 days ago"

The above statement will be analysed from left to right, and statements in brackets will be evaluated as a single attribute. So the query will retrieve all customers whose delivery address city is London OR who has an average order value greater than £250 ONLY if they also have a last order date more recent than 90 days ago.

We can also nest brackets within brackets. The below query will return either customers who are in London AND are Pubs, OR those whose average order value is greater than £250, as long as their last order date is more recent than 90 days ago.

((delivery_address_city = "London" and type.type = "Pub") or average_order_value > 250) and last_order_date < "90 days ago"


Dates

BrewwQL allows you to filter on dates, and has a powerful natural language understanding. For example, if you'd like all customers who have ordered since the 1st January 2020, you can simply enter last_order_date > "1st January 2020" or last_order_date > "01/01/2020" or even last_order_date > "1 Jan 2020".

BrewwQL also understands relative dates, so you can filter on the last 30 days with last_order_date > "30 days ago" or filter on the last two months with last_order_date > "2 months ago".

A date is greater > than another if it is more recent, and less < than another if it is older.


Case-sensitivity

Do capitals matter in my searches? No, a search for delivery_address_city = "London" and delivery_address_city = "london" will return the same results.


Operator reference

Operator Meaning Example Verbose
= Equal to name = "The Shop" Where the name is equal to "The Shop"
!= Not equal to name != "The Shop" Where the name is not equal to "The Shop"
~ Contains name ~ "The" Where the name contains "The"
!~ Does not contain name !~ "The" Where the name does not contain "The"
> Greater than average_order_value > 100 Where the average order value is greater than 100
>= Greater than or equal to average_order_value >= 100 Where the average order value is greater than or equal to 100
< Less than average_order_value < 100 Where the average order value is less than 100
<= Less than or equal to average_order_value <= 100 Where the average order value is less than or equal to 100
in In name in ("The Shop", "The Pub", "The Restaurant") Where the name is either "The Shop" or "The Pub" or "The Restaurant"
not in Not in name not in ("The Shop", "The Pub", "The Restaurant") Where the name is not "The Shop" and not "The Pub" and not "The Restaurant"