query()
creates a query to be used for fetching mentions, or
for counting them. You probably want to avoid using this directly,
and use one of the query verbs instead, such as filter_mentions()
.
to_query()
is a convenient way to create a query object from
other things, such as an account()
.
query( accounts = NULL, brands = NULL, timezones = NULL, filter = NULL, comparison = NULL, fields = NULL, grouping = NULL, ordering = NULL )
accounts | A character vector of accounts to use. |
---|---|
brands | A list of brands to query against. |
timezones | The timezones to report dates in when counting mentions. |
filter | The filter to use when fetching or counting mentions. |
comparison | A list of subfilters to use when counting mentions. |
fields | Extra fields to return when fetching or counting mentions. |
grouping | How to group mentions when counting them. |
ordering | The order to return results in. |
A query object
The query object is accepted by count_mentions()
and mentions()
.
The advantage of using query and its various verbs is that it handles
adding root brands to your filter for you, as well as filtering out
mentions using older versions of the API, or who have no brands altogether.
Of special note, V4 accounts will not be added to a query.
Various functions can be chained together using the pipe operator as 'verbs' in a query sentence.
filter_mentions()
lets you choose what mentions to count or fetch.
group_mentions_by()
lets you group mentions when counting.
compare_mentions()
lets you count and compare mentions from subfilters.
with_mention_fields()
lets you select extra information fields, such as OTS, or engagement.
with_mention_order()
lets you order the results.
The filter language often uses IDs to represent countries, languages, and so on. These can be found by using either the filter panel in Analyse, or the data model functions.
get_query_brands()
returns a list of filter_brand()
objects. This
prints nicely, for examining all brands in a query.
get_query_accounts()
returns a vector of account codes. This prints
nicely, for examining all accounts involved in a query.
You can test if an object is a query()
object using is_query()
.
to_count_filter()
will allow you to convert a query()
to
a vector of filters appropriate for use on count_mentions()
.
to_mention_filter()
is similar, but for the mentions()
function.
query(accounts = c("TEST01AA", "TEST02AA"), filter = "published inthelast week", timezone = "UTC", brands = list(filter_brand(1), filter_brand(2)) )#> BrandsEye Query #> accounts: TEST01AA, TEST02AA #> brands: 1, 2 #> timezones: UTC #> filter: published inthelast week