added twitter search heuristic

pull/1/head
orbiter 13 years ago
parent fcd5c7eec3
commit a55e77a115

@ -1012,6 +1012,7 @@ about.body =
# search heuristics # search heuristics
heuristic.site = false heuristic.site = false
heuristic.blekko = false heuristic.blekko = false
heuristic.twitter = false
heuristic.searchresults = false heuristic.searchresults = false
heuristic.searchresults.crawlglobal = false heuristic.searchresults.crawlglobal = false

@ -71,6 +71,19 @@
</fieldset> </fieldset>
</form> </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"> <form id="HeuristicFormBlekko" method="post" action="ConfigHeuristics_p.html" enctype="multipart/form-data" accept-charset="UTF-8">
<fieldset> <fieldset>
<legend> <legend>

@ -51,12 +51,15 @@ public class ConfigHeuristics_p {
if (post.containsKey("searchresultglobal_off")) sb.setConfig("heuristic.searchresults.crawlglobal", false); 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_on")) sb.setConfig("heuristic.blekko", true);
if (post.containsKey("blekko_off")) sb.setConfig("heuristic.blekko", false); 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("site.checked", sb.getConfigBool("heuristic.site", false) ? 1 : 0);
prop.put("searchresult.checked", sb.getConfigBool("heuristic.searchresults", 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("searchresultglobal.checked", sb.getConfigBool("heuristic.searchresults.crawlglobal", false) ? 1 : 0);
prop.put("blekko.checked", sb.getConfigBool("heuristic.blekko", 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; return prop;
} }

@ -93,6 +93,7 @@ public class ConfigNetwork_p
// remove heuristics // remove heuristics
sb.setConfig("heuristic.site", false); sb.setConfig("heuristic.site", false);
sb.setConfig("heuristic.blekko", false); sb.setConfig("heuristic.blekko", false);
sb.setConfig("heuristic.twitter", false);
} }
final boolean robinsonmode = "robinson".equals(post.get("network", "")); final boolean robinsonmode = "robinson".equals(post.get("network", ""));
if ( robinsonmode ) { if ( robinsonmode ) {

@ -539,6 +539,12 @@ public class yacysearch {
querystring = querystring.replace("/heuristic/blekko", ""); querystring = querystring.replace("/heuristic/blekko", "");
modifier.append("/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); final int authori = querystring.indexOf("author:", 0);
String authorhash = null; String authorhash = null;
@ -830,6 +836,9 @@ public class yacysearch {
if ( (heuristicBlekko >= 0 || sb.getConfigBool("heuristic.blekko", false)) && authenticated ) { if ( (heuristicBlekko >= 0 || sb.getConfigBool("heuristic.blekko", false)) && authenticated ) {
sb.heuristicRSS("http://blekko.com/ws/$+/rss", theSearch, "blekko"); 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 // log

@ -1208,6 +1208,7 @@ public final class Switchboard extends serverSwitch
// remove heuristics // remove heuristics
setConfig("heuristic.site", false); setConfig("heuristic.site", false);
setConfig("heuristic.blekko", false); setConfig("heuristic.blekko", false);
setConfig("heuristic.twitter", false);
// relocate // relocate
this.peers.relocate( this.peers.relocate(

Loading…
Cancel
Save