mistake corrected

cleanup

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4454 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
borg-0300 17 years ago
parent a9c4e9c309
commit d1758eb17d

@ -59,43 +59,69 @@ public final class search {
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) { public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
// return variable that accumulates replacements // return variable that accumulates replacements
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
sb.remoteSearchLastAccess = System.currentTimeMillis();
serverObjects prop = new serverObjects(); serverObjects prop = new serverObjects();
if ((post == null) || (env == null)) return prop; // defaults
if (!yacyNetwork.authentifyRequest(post, env)) return prop;
//System.out.println("yacy: search received request = " + post.toString());
final String oseed = post.get("myseed", ""); // complete seed of the requesting peer
// final String youare = post.get("youare", ""); // seed hash of the target peer, used for testing network stability
final String key = post.get("key", ""); // transmission key for response
final yacySeed otherPeer = yacySeed.genRemoteSeed(oseed, key, false);
if (otherPeer == null) {
prop.put("links", ""); prop.put("links", "");
prop.put("linkcount", "0"); prop.put("linkcount", "0");
prop.put("references", ""); prop.put("references", "");
if (post == null || env == null || !yacyNetwork.authentifyRequest(post, env)) {
return prop;
}
// test:
// http://localhost:8080/yacy/search.html?query=4galTpdpDM5Q (search for linux)
// http://localhost:8080/yacy/search.html?query=gh8DKIhGKXws (search for book)
// http://localhost:8080/yacy/search.html?query=UEhMGfGv2vOE (search for kernel)
// http://localhost:8080/yacy/search.html?query=ZX-LjaYo74PP (search for help)
// http://localhost:8080/yacy/search.html?query=uDqIalxDfM2a (search for mail)
// http://localhost:8080/yacy/search.html?query=4galTpdpDM5Qgh8DKIhGKXws&abstracts=auto (search for linux and book, generate abstract automatically)
// http://localhost:8080/yacy/search.html?query=&abstracts=4galTpdpDM5Q (only abstracts for linux)
final plasmaSwitchboard sb = (plasmaSwitchboard) env;
if (sb.isRobinsonMode() &&
!(sb.isPublicRobinson() ||
sb.isInMyCluster((String)header.get(httpHeader.CONNECTION_PROP_CLIENTIP)))) {
// if we are a robinson cluster, answer only if this client is known by our network definition
return prop; return prop;
} }
otherPeer.setLastSeenUTC();
final String query = post.get("query", ""); // a string of word hashes that shall be searched and combined final String query = post.get("query", ""); // a string of word hashes that shall be searched and combined
final String exclude= post.get("exclude", "");// a string of word hashes that shall not be within the search result
String urls = post.get("urls", ""); // a string of url hashes that are preselected for the search: no other may be returned
String abstracts = post.get("abstracts", ""); // a string of word hashes for abstracts that shall be generated, or 'auto' (for maxcount-word), or '' (for none) String abstracts = post.get("abstracts", ""); // a string of word hashes for abstracts that shall be generated, or 'auto' (for maxcount-word), or '' (for none)
if ((query == null || query.length() == 0) & (abstracts == null || abstracts.length() == 0)) {
return prop;
}
// tell all threads to do nothing for a specific time
sb.intermissionAllThreads(3000);
sb.remoteSearchLastAccess = System.currentTimeMillis();
final String oseed = post.get("myseed", ""); // complete seed of the requesting peer
final String key = post.get("key", ""); // transmission key for response
final yacySeed opeer = yacySeed.genRemoteSeed(oseed, key, true);
// store accessing peer
if (yacyCore.seedDB == null) {
yacyCore.log.logSevere("yacy.search: seed cache not initialized");
} else {
yacyCore.peerActions.peerArrival(opeer, true);
}
// final String youare = post.get("youare", ""); // seed hash of the target peer, used for testing network stability
// final String fwdep = post.get("fwdep", ""); // forward depth. if "0" then peer may NOT ask another peer for more results // final String fwdep = post.get("fwdep", ""); // forward depth. if "0" then peer may NOT ask another peer for more results
// final String fwden = post.get("fwden", ""); // forward deny, a list of seed hashes. They may NOT be target of forward hopping // final String fwden = post.get("fwden", ""); // forward deny, a list of seed hashes. They may NOT be target of forward hopping
String profile = post.get("profile", ""); // remote profile hand-over
String urls = post.get("urls", ""); // a string of url hashes that are preselected for the search: no other may be returned
final String exclude = post.get("exclude", ""); // a string of word hashes that shall not be within the search result
final int count = Math.min(100, post.getInt("count", 10)); // maximum number of wanted results final int count = Math.min(100, post.getInt("count", 10)); // maximum number of wanted results
final int maxdist= post.getInt("maxdist", Integer.MAX_VALUE); final int maxdist = post.getInt("maxdist", Integer.MAX_VALUE);
final String prefer = post.get("prefer", ""); final String prefer = post.get("prefer", "");
final String contentdom = post.get("contentdom", "text");
final String filter = post.get("filter", ".*"); final String filter = post.get("filter", ".*");
final int partitions = post.getInt("partitions", 30); final int partitions = post.getInt("partitions", 30);
String profile = post.get("profile", ""); // remote profile hand-over final String contentdom = post.get("contentdom", "text");
if (profile.length() > 0) profile = crypt.simpleDecode(profile, null); if (profile.length() > 0) profile = crypt.simpleDecode(profile, null);
//final boolean includesnippet = post.get("includesnippet", "false").equals("true"); //final boolean includesnippet = post.get("includesnippet", "false").equals("true");
kelondroBitfield constraint = ((post.containsKey("constraint")) && (post.get("constraint", "").length() > 0)) ? new kelondroBitfield(4, post.get("constraint", "______")) : null; kelondroBitfield constraint = ((post.containsKey("constraint")) && (post.get("constraint", "").length() > 0)) ? new kelondroBitfield(4, post.get("constraint", "______")) : null;
if (constraint != null) { if (constraint != null) {
// check bad handover parameter from older versions // check bad handover parameter from older versions
@ -108,39 +134,10 @@ public final class search {
// final boolean global = ((String) post.get("resource", "global")).equals("global"); // if true, then result may consist of answers from other peers // final boolean global = ((String) post.get("resource", "global")).equals("global"); // if true, then result may consist of answers from other peers
// Date remoteTime = yacyCore.parseUniversalDate((String) post.get(yacySeed.MYTIME)); // read remote time // Date remoteTime = yacyCore.parseUniversalDate((String) post.get(yacySeed.MYTIME)); // read remote time
// test:
// http://localhost:8080/yacy/search.html?query=4galTpdpDM5Q (search for linux)
// http://localhost:8080/yacy/search.html?query=gh8DKIhGKXws (search for book)
// http://localhost:8080/yacy/search.html?query=UEhMGfGv2vOE (search for kernel)
// http://localhost:8080/yacy/search.html?query=ZX-LjaYo74PP (search for help)
// http://localhost:8080/yacy/search.html?query=uDqIalxDfM2a (search for mail)
// http://localhost:8080/yacy/search.html?query=4galTpdpDM5Qgh8DKIhGKXws&abstracts=auto (search for linux and book, generate abstract automatically)
// http://localhost:8080/yacy/search.html?query=&abstracts=4galTpdpDM5Q (only abstracts for linux)
if ((sb.isRobinsonMode()) &&
(!((sb.isPublicRobinson()) ||
(sb.isInMyCluster((String)header.get(httpHeader.CONNECTION_PROP_CLIENTIP)))))) {
// if we are a robinson cluster, answer only if this client is known by our network definition
prop.put("links", "");
prop.put("linkcount", "0");
prop.put("references", "");
return prop;
}
// tell all threads to do nothing for a specific time
sb.intermissionAllThreads(3000);
TreeSet<String> abstractSet = ((abstracts.length() == 0) || (abstracts.equals("auto"))) ? null : plasmaSearchQuery.hashes2Set(abstracts);
// store accessing peer
if (yacyCore.seedDB == null) {
yacyCore.log.logSevere("yacy.search: seed cache not initialized");
} else {
yacyCore.peerActions.peerArrival(yacySeed.genRemoteSeed(oseed, key, true), true);
}
// prepare search // prepare search
final TreeSet<String> queryhashes = plasmaSearchQuery.hashes2Set(query); final TreeSet<String> queryhashes = plasmaSearchQuery.hashes2Set(query);
final TreeSet<String> abstractSet = (abstracts.length() == 0 || abstracts.equals("auto")) ? null : plasmaSearchQuery.hashes2Set(abstracts);
final TreeSet<String> excludehashes = (exclude.length() == 0) ? new TreeSet<String>(kelondroBase64Order.enhancedComparator) : plasmaSearchQuery.hashes2Set(exclude); final TreeSet<String> excludehashes = (exclude.length() == 0) ? new TreeSet<String>(kelondroBase64Order.enhancedComparator) : plasmaSearchQuery.hashes2Set(exclude);
final long timestamp = System.currentTimeMillis(); final long timestamp = System.currentTimeMillis();
@ -175,7 +172,6 @@ public final class search {
indexabstract.append("indexabstract." + wordhash + "=").append(indexContainer.compressIndex(container, null, 1000).toString()).append(serverCore.CRLF_STRING); indexabstract.append("indexabstract." + wordhash + "=").append(indexContainer.compressIndex(container, null, 1000).toString()).append(serverCore.CRLF_STRING);
} }
} }
prop.put("indexcount", ""); prop.put("indexcount", "");
prop.put("joincount", "0"); prop.put("joincount", "0");
prop.put("references", ""); prop.put("references", "");
@ -260,14 +256,7 @@ public final class search {
prop.put("indexabstract", indexabstract.toString()); prop.put("indexabstract", indexabstract.toString());
// prepare result // prepare result
if ((joincount == 0) || (accu == null)) { if (joincount != 0 || accu != null) {
// no results
prop.put("links", "");
prop.put("linkcount", "0");
prop.put("references", "");
} else {
// result is a List of urlEntry elements // result is a List of urlEntry elements
long timer = System.currentTimeMillis(); long timer = System.currentTimeMillis();
StringBuffer links = new StringBuffer(); StringBuffer links = new StringBuffer();
@ -313,10 +302,9 @@ public final class search {
prop.put("searchtime", System.currentTimeMillis() - timestamp); prop.put("searchtime", System.currentTimeMillis() - timestamp);
final int links = Integer.parseInt(prop.get("linkcount","0")); final int links = Integer.parseInt(prop.get("linkcount", "0"));
yacyCore.seedDB.mySeed().incSI(links); yacyCore.seedDB.mySeed().incSI(links);
yacyCore.seedDB.mySeed().incSU(links); yacyCore.seedDB.mySeed().incSU(links);
return prop; return prop;
} }
} }

Loading…
Cancel
Save