BFQL¶
The Big Friendly Query Language (BFQL - “buffquill”) is a very simple way to match objects by tag-values. BFQL is designed to be expressive and easy to read from a human perspective. BFQL is an English query language in that its keywords come from English natural language.
BFQL is used in three ways, to match:
objects where a list of specified tag-values are returned,
objects that require a bulk update of specific tag-values, or
objects from which specified tags should be deleted.
The BFQL is heavily inspired by the query language created for FluidInfo.
Tags are written as a unique namespace/tag path.
The following kinds of queries are possible and depend on the type of the tag used in the query.
All Tags¶
The type of the tag makes no difference to these sorts of query.
Presence:
has library/titlewill return all objects that have values annotated by thelibrary/titletag.Absence:
missing library/titlewill return all objects that have NOT been annotated with thelibrary/titletag. Due to the potential for huge numbers of results, this query can only be used in conjuntion with another via theandoperator.Conjugation (and):
library/summary matches "whales" and library/pages < 100will return all objects that have thelibrary/summaryandlibrary/pagestags and whose values match"whales"andless than 100respectively.Disjunction (or):
library/summary matches "whales" or library/summary matches "dolphins"will return all objects that have thelibrary/summarytag and whose value matches either"whales"or"dolphins".Grouping:
has library/title and (nicholas/rating > 5 or terry/rating > 7)returns all objects where the queries within the parenthesis are evaluated together before being conjugated with the results of the outer query to produce the final result set of object_ids.
String Based Tags¶
The following queries are possible on tags that are a type of string
(representing arbitrary textual data) or pointer (representing a URL pointing
to something elsewhere on the internet).
When writing strings, enclose them within double quotes.
Equality:
library/title is "Moby Dick"will return all objects with thelibrary/titletag whose value is exactly"Moby Dick".Case insensitive equality:
library/author iis "moby dick"will return all objects with thelibrary/titletag whose value is a case insensitive match for"moby dick".Text matching:
library/summary matches "whales"will return all objects with thelibrary/summarytag whose value contains a case-sensitive match of the word"whales".Case insensitive text matching:
library/summary imatches "whales"will return all objects with thelibrary/summarytag whose value contains a case-INsensitive match of the word"whales".
Boolean Tags¶
The following queries work on tags that are boolean.
Truth:
nicholas/has_met is truewill return all objects with thenicholas/has_mettag whose value is true.Falsity:
nicholas/has_met is falsewill return all objects with thenicholas/has_mettag whose value is false.
Scalar Tags¶
The following queries only work with scalar tags: integer, float,
datetime and duration.
Integer and float values can be used with each other for comparison.
Integers are written as a sequence of digits: 1234
Floats are written as a sequence of digits with a decimal point: 1.234
Datetimes are written precisely to the second: 2020-09-24T15:30:30
(YYYY-MM-DDTHH:MM:SS with the T separating the date and time portions for
readability reasons) or with just the date: 2020-09-24 (YYYY-MM-DD).
Timezone offset may also be appended 2020-09-24T15:30:30-08:00
(YYYY-MM-DDTHH:MM:SS[+|-]HH:MM). These patterns follow the recommendations
in the W3C’s Date and Time Formats Note.
Durations are expressed as exact numbers of days (denoted by an integer
followed by d) or seconds (an integer followed by s): 12d or
360s. Other durations should be constructed by multiplying days or seconds to
the right value.
Equal:
game/score = 1000will return all objects with thegame/scoretag whose value is exactly the integer1000.Not equal:
game/score != 1000will return all objects with thegame/scoretag whose value is NOT equal to the integer1000.Greater than:
bookshop/delivery_weight_kg > 1.2will return all objects with thebookshop/delivery_weight_kgtag whose value is greater than the float1.2.Less than:
bookshop/delivery_weight_kg < 1.5will return all objects with thebookshop/delivery_weight_kgtag whose value is less than the float1.5.Greater than or equal to:
employee/dob >= 1973-08-19will return all objects with theemployee/dobtag whose value is greater than or equal to the date1973-08-19(19th August, 1973).Less than or equal to:
employee/probation_period <= 365dwill return all objects with theemployee/probation_periodtag whose value is less than or equal to a duration of 365 days (365d).
Binary Tags¶
Binary tags are, by their nature opaque (they store arbitrary binary information). However they do automatically store the value’s MIME type.
Type of:
library/audiobook is mime:audio/mpegwill return all objects with thelibrary/audiobooktag whose mime type is listed asaudio/mpeg(i.e. MP3). MIME type information is always treated as case insensitive and must start withmime:(to differentiate MIME values from tag paths).
The current list of valid MIME types (and what file types they represent) can be found on the IANA’s website.