Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

added twitter search heuristic

orbitera55e77a115c3
diff --git a/defaults/yacy.init b/defaults/yacy.init
index 46372621e..13dd88b93 100644
--- a/defaults/yacy.init
+++ b/defaults/yacy.init
@@ -1012,6 +1012,7 @@ about.body =
# search heuristics
heuristic.site = false
heuristic.blekko = false
+heuristic.twitter = false
heuristic.searchresults = false
heuristic.searchresults.crawlglobal = false
diff --git a/htroot/ConfigHeuristics_p.html b/htroot/ConfigHeuristics_p.html
index 57fc7cd5e..365b32bd2 100644
--- a/htroot/ConfigHeuristics_p.html
+++ b/htroot/ConfigHeuristics_p.html
@@ -71,6 +71,19 @@
</fieldset>
</form>
+ <form id="HeuristicFormTwitter" method="post" action="ConfigHeuristics_p.html" enctype="multipart/form-data" accept-charset="UTF-8">
+ <fieldset>
+ <legend>
+ <input type="checkbox" name="twitter_check" id="twitter" onclick="window.location.href='ConfigHeuristics_p.html?#(twitter.checked)#twitter_on=::twitter_off=#(/twitter.checked)#'" value="twitter"#(twitter.checked)#:: checked="checked"#(/twitter.checked)# />
+ <label for="twitter">twitter: load external search result list from <a href="http://search.twitter.com">twitter</a></label>
+ </legend>
+ <p>
+ When using this heuristic, then every search request line is used for a call to twitter.
+ 50 results are taken from twitter and loaded simultanously, parsed and indexed immediately.
+ </p>
+ </fieldset>
+ </form>
+
<form id="HeuristicFormBlekko" method="post" action="ConfigHeuristics_p.html" enctype="multipart/form-data" accept-charset="UTF-8">
<fieldset>
<legend>
diff --git a/htroot/ConfigHeuristics_p.java b/htroot/ConfigHeuristics_p.java
index c3287829f..ed8dd66b9 100644
--- a/htroot/ConfigHeuristics_p.java
+++ b/htroot/ConfigHeuristics_p.java
@@ -51,12 +51,15 @@ public class ConfigHeuristics_p {
if (post.containsKey("searchresultglobal_off")) sb.setConfig("heuristic.searchresults.crawlglobal", false);
if (post.containsKey("blekko_on")) sb.setConfig("heuristic.blekko", true);
if (post.containsKey("blekko_off")) sb.setConfig("heuristic.blekko", false);
+ if (post.containsKey("twitter_on")) sb.setConfig("heuristic.twitter", true);
+ if (post.containsKey("twitter_off")) sb.setConfig("heuristic.twitter", false);
}
prop.put("site.checked", sb.getConfigBool("heuristic.site", false) ? 1 : 0);
prop.put("searchresult.checked", sb.getConfigBool("heuristic.searchresults", false) ? 1 : 0);
prop.put("searchresultglobal.checked", sb.getConfigBool("heuristic.searchresults.crawlglobal", false) ? 1 : 0);
prop.put("blekko.checked", sb.getConfigBool("heuristic.blekko", false) ? 1 : 0);
+ prop.put("twitter.checked", sb.getConfigBool("heuristic.twitter", false) ? 1 : 0);
return prop;
}
diff --git a/htroot/ConfigNetwork_p.java b/htroot/ConfigNetwork_p.java
index 6b4633305..e15d31840 100644
--- a/htroot/ConfigNetwork_p.java
+++ b/htroot/ConfigNetwork_p.java
@@ -93,6 +93,7 @@ public class ConfigNetwork_p
// remove heuristics
sb.setConfig("heuristic.site", false);
sb.setConfig("heuristic.blekko", false);
+ sb.setConfig("heuristic.twitter", false);
}
final boolean robinsonmode = "robinson".equals(post.get("network", ""));
if ( robinsonmode ) {
diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java
index 2cb580937..e0dc5f421 100644
--- a/htroot/yacysearch.java
+++ b/htroot/yacysearch.java
@@ -539,6 +539,12 @@ public class yacysearch {
querystring = querystring.replace("/heuristic/blekko", "");
modifier.append("/heuristic/blekko ");
}
+
+ final int heuristicTwitter = querystring.indexOf("/heuristic/twitter", 0);
+ if ( heuristicBlekko >= 0 ) {
+ querystring = querystring.replace("/heuristic/twitter", "");
+ modifier.append("/heuristic/twitter ");
+ }
final int authori = querystring.indexOf("author:", 0);
String authorhash = null;
@@ -830,6 +836,9 @@ public class yacysearch {
if ( (heuristicBlekko >= 0 || sb.getConfigBool("heuristic.blekko", false)) && authenticated ) {
sb.heuristicRSS("http://blekko.com/ws/$+/rss", theSearch, "blekko");
}
+ if ( (heuristicTwitter >= 0 || sb.getConfigBool("heuristic.twitter", false)) && authenticated ) {
+ sb.heuristicRSS("http://search.twitter.com/search.rss?rpp=50&q=$", theSearch, "twitter");
+ }
}
// log
diff --git a/source/net/yacy/search/Switchboard.java b/source/net/yacy/search/Switchboard.java
index 2b833ec93..ef48e3584 100644
--- a/source/net/yacy/search/Switchboard.java
+++ b/source/net/yacy/search/Switchboard.java
@@ -1208,6 +1208,7 @@ public final class Switchboard extends serverSwitch
// remove heuristics
setConfig("heuristic.site", false);
setConfig("heuristic.blekko", false);
+ setConfig("heuristic.twitter", false);
// relocate
this.peers.relocate(