Tag keyword
The tag keyword in CSDL allows you to add metadata to objects in DataSift. Imagine you are running a stream to look for news about new car launches. You can add an "Audi" tag to all the objects that mention Audi, "Jeep" to all the objects that mention Jeeps, and so on.
Tags make subsequent processing easier. Just as augmentations enrich objects based on information supplied by third-party sites, tags enrich objects according to rules you define in your CSDL code.
To define a tag, write the condition in braces and use the tag keyword followed by the name of the associated attribute like this.
tag "Audi" { interaction.content contains "Audi" }
Then enclose the body of the filter in a return statement:
return {
interaction.content contains_any "Detroit auto show,
New York auto show,
Geneva motor show"
}
There is no limit to the number of tags you can use.
You can also add tags to existing streams or streams defined by other people. For instance:
tag "APPLE" {stream "f0596f03644177b8bf5b59708a08bfe8"}
return {
stream "f0596f03644177b8bf5b59708a08bfe8"
}
However, tags do not cascade. If that original stream had tags, they will not be present in your output stream. The only tag that you will see in output objects is the "APPLE" tag shown in the code above. In other words,only the top-level tags will be available for further processing.
Tags are part of the interaction object in a Tweet.
When you add tags to your CSDL, they can increase your billing for that stream slightly.
Examples
1. Filter for posts that mention "Apple" and add multiple tags.
2. Tags are also useful when you merge several streams into one master stream. You can add a tag to each input object to identify which stream they originated from.
3. Tags do not cascade. For example, we wrote this stream and DataSift gave it a hash of f2625cb00dcbbe4121b654d9d3e1f3aa
This stream finds all objects that mention Apple, Mac, iPad, or Steve Jobs. For the ones that contain Steve Jobs, it adds a "Steve Jobs" tag.
We can use the stream in a new stream and add new tags like this:
However, because tags do not cascade, the only tags In the output will be "test".
