Created
December 3, 2013 03:03
-
-
Save cpdean/7763254 to your computer and use it in GitHub Desktop.
Getting keywords out of a search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.example.util.Codec | |
import com.example.storm.bolts.IntervalBolt | |
import com.github.theon.uri.Uri.parseUri | |
class SomeBolt (serializer:Serializer, ticksBeforeFlush: Int, bufferLimit: Int) | |
extends IntervalBolt(ticksBeforeFlush) with Codec{ | |
def bufferOffInterval(input: Tuple) = ??? | |
def onInterval() = ??? | |
override def declareOutputFields(declarer:OutputFieldsDeclarer) = ??? | |
def extractKeywords(category: String, url: String) : List[String] = { | |
val query_key = if (url.contains("http://search.yahoo.com/")) "p" else "q" | |
if (category == "search") | |
parseUri(url).query.params.getOrElse(query_key, List()).flatMap(x => x.decodeUrl.split(" ")) | |
else List() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment