Creating a Query¶
Queries are specified in files separate from the code that runs them. This modularity avoids hard coding the queries into the code itself and risking them being accidentally overwritten or modified between searches. Placing queries in their own files also makes them easier to share them, promoting transparency and replicability.
All data is organized around an event name. This name should be a unique signifier for the focal event around which you want to collect data.
The event name is specified through the name of the query file. For example, say we want to search for tweets about Facebook’s Oversight Board. Then we can name our event “facebook_oversight” and create a corresponding search query file
facebook_oversight.yaml. The query file should be placed in the appropriate
input directory. For example, if we are running a Twitter search, then we will place our query file in the directory
The structure and syntax of the query file depends on the platform being queried and the endpoint’s query operators.
Twitter search query files are YAML files with three fields:
queries field allows you to list multiple queries sequentially, each of which will be sent to the Twitter API. The start and end times follow the RFC 3339 format, e.g. YYYY-MM-DDT00:00:00Z
Twitter Filter Stream¶
Twitter filter stream query files are YAML files with one field:
rules field allows you to list multiple filter rules sequentially, each of which will be sent to the Twitter API. Each rule should have two fields itself:
value is the filter rule itself. The
tag is a colloquial description of the filter rule.