Introduction
At Motto we realized that our APIs expose a number of endpoints that need support for filters of varying complexity. For example, in our content-delivery API you may wish to retrieve all events between two dates, where the event status is either scheduled or started, where the event is a football match with at least 500 views, and where the home-team has at least two Spanish players on the team. To support such advanced filtering, we decided that many (though not all) of our list endpoints should expose afilter
parameter, which expects a KQL query. The following section details how to construct such a query.
Each Motto service determines which subset of the KQL specification it needs to support, and which fields you are allowed to query on.
We recommend reading the docstrings of the API carefully, and validating that the result-sets match your expectations.
KQL implementation
The Kibana Query Language was developed with Elastic Search in mind, and while we do not use this directly in combination with Elastic Search, we still believe this DSL is intuitive and easy to write for most technical users.Basic queries
Most of the Studio API endpoints support only the “basic” types of queries detailed in this section. To query a single field and match against an exact term, use the following syntax:AND
explicitly, that is supported, too.
If the
filter
is passed a URL parameter, make sure to URL-encode queries like the one above.<
, <=
, >
, >=
):
Advanced queries
Besides the operators and functionality listed in the section above, some services may support more advanced filters. To query two fields where only a single match is needed, use the following syntax:*
needs to be the trailing character):
The following characters must be escaped if they are part of the actual query term:
\
(
)
:
<
>
"
*