|
|
|
@ -401,7 +401,7 @@ public final class yacyClient {
|
|
|
|
|
final long timestamp = System.currentTimeMillis();
|
|
|
|
|
SearchResult result;
|
|
|
|
|
try {
|
|
|
|
|
result = searchClient(
|
|
|
|
|
result = new SearchResult(
|
|
|
|
|
yacyNetwork.basicRequestParts(Switchboard.getSwitchboard(), target.hash, crypt.randomSalt()),
|
|
|
|
|
mySeed, wordhashes, excludehashes, urlhashes, prefer, filter, language,
|
|
|
|
|
sitehash, authorhash, count, maxDistance, global, partitions, target.getHexHash() + ".yacyh", target.getClusterAddress(),
|
|
|
|
@ -411,7 +411,6 @@ public final class yacyClient {
|
|
|
|
|
//yacyCore.peerActions.peerDeparture(target, "search request to peer created io exception: " + e.getMessage());
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if (result == null) return -1;
|
|
|
|
|
// computation time
|
|
|
|
|
final long totalrequesttime = System.currentTimeMillis() - timestamp;
|
|
|
|
|
|
|
|
|
@ -553,7 +552,22 @@ public final class yacyClient {
|
|
|
|
|
return result.urlcount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static SearchResult searchClient(
|
|
|
|
|
public static class SearchResult {
|
|
|
|
|
|
|
|
|
|
public String version; // version : application version of responder
|
|
|
|
|
public String uptime; // uptime : uptime in seconds of responder
|
|
|
|
|
public String fwhop; // hops (depth) of forwards that had been performed to construct this result
|
|
|
|
|
public String fwsrc; // peers that helped to construct this result
|
|
|
|
|
public String fwrec; // peers that would have helped to construct this result (recommendations)
|
|
|
|
|
public int urlcount; // number of returned LURL's for this search
|
|
|
|
|
public int joincount; //
|
|
|
|
|
public Map<byte[], Integer> indexcount; //
|
|
|
|
|
public long searchtime; // time that the peer actually spent to create the result
|
|
|
|
|
public String[] references; // search hints, the top-words
|
|
|
|
|
public List<URIMetadataRow> links; // LURLs of search
|
|
|
|
|
public Map<byte[], String> indexabstract; // index abstracts, a collection of url-hashes per word
|
|
|
|
|
|
|
|
|
|
public SearchResult(
|
|
|
|
|
LinkedHashMap<String,ContentBody> parts,
|
|
|
|
|
final yacySeed mySeed,
|
|
|
|
|
final String wordhashes,
|
|
|
|
@ -572,8 +586,7 @@ public final class yacyClient {
|
|
|
|
|
String hostaddress,
|
|
|
|
|
final SearchEvent.SecondarySearchSuperviser secondarySearchSuperviser,
|
|
|
|
|
final RankingProfile rankingProfile,
|
|
|
|
|
final Bitfield constraint
|
|
|
|
|
) throws IOException {
|
|
|
|
|
final Bitfield constraint) throws IOException {
|
|
|
|
|
// send a search request to peer with remote Hash
|
|
|
|
|
|
|
|
|
|
// INPUT:
|
|
|
|
@ -612,30 +625,12 @@ public final class yacyClient {
|
|
|
|
|
resultMap = FileUtils.table(HTTPConnector.getConnector(HTTPLoader.crawlerUserAgent).post(new MultiProtocolURI("http://" + hostaddress + "/yacy/search.html"), 60000, hostname, parts));
|
|
|
|
|
//resultMap = FileUtils.table(HTTPConnector.getConnector(HTTPLoader.crawlerUserAgent).post(new MultiProtocolURI("http://" + target.getClusterAddress() + "/yacy/search.html"), 60000, target.getHexHash() + ".yacyh", parts));
|
|
|
|
|
|
|
|
|
|
// evaluate request result
|
|
|
|
|
if (resultMap == null || resultMap.isEmpty()) throw new IOException("resultMap is NULL");
|
|
|
|
|
return new SearchResult(resultMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class SearchResult {
|
|
|
|
|
|
|
|
|
|
public String version; // version : application version of responder
|
|
|
|
|
public String uptime; // uptime : uptime in seconds of responder
|
|
|
|
|
public String fwhop; // hops (depth) of forwards that had been performed to construct this result
|
|
|
|
|
public String fwsrc; // peers that helped to construct this result
|
|
|
|
|
public String fwrec; // peers that would have helped to construct this result (recommendations)
|
|
|
|
|
public int urlcount; // number of returned LURL's for this search
|
|
|
|
|
public int joincount; //
|
|
|
|
|
public Map<byte[], Integer> indexcount; //
|
|
|
|
|
public long searchtime; // time that the peer actually spent to create the result
|
|
|
|
|
public String[] references; // search hints, the top-words
|
|
|
|
|
public List<URIMetadataRow> links; // LURLs of search
|
|
|
|
|
public Map<byte[], String> indexabstract; // index abstracts, a collection of url-hashes per word
|
|
|
|
|
|
|
|
|
|
public SearchResult(Map<String, String> resultMap) throws IOException {
|
|
|
|
|
try {
|
|
|
|
|
this.searchtime = Integer.parseInt(resultMap.get("searchtime"));
|
|
|
|
|
} catch (final NumberFormatException e) {
|
|
|
|
|
throw new IOException("wrong output format for searchtime: " + e.getMessage());
|
|
|
|
|
throw new IOException("wrong output format for searchtime: " + e.getMessage() + ", map = " + resultMap.toString());
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
this.joincount = Integer.parseInt(resultMap.get("joincount")); // the complete number of hits at remote site
|
|
|
|
@ -1104,7 +1099,7 @@ public final class yacyClient {
|
|
|
|
|
long time = System.currentTimeMillis();
|
|
|
|
|
SearchResult result;
|
|
|
|
|
try {
|
|
|
|
|
result = searchClient(
|
|
|
|
|
result = new SearchResult(
|
|
|
|
|
yacyNetwork.basicRequestParts((String) null, (String) null, "freeworld"),
|
|
|
|
|
null, // sb.peers.mySeed(),
|
|
|
|
|
new String(wordhashe),
|
|
|
|
@ -1124,14 +1119,10 @@ public final class yacyClient {
|
|
|
|
|
new RankingProfile(ContentDomain.TEXT), // rankingProfile,
|
|
|
|
|
null // constraint);
|
|
|
|
|
);
|
|
|
|
|
if (result == null) {
|
|
|
|
|
System.out.println("no response");
|
|
|
|
|
} else {
|
|
|
|
|
for (URIMetadataRow link: result.links) {
|
|
|
|
|
System.out.println(link.metadata().url().toNormalform(true, false));
|
|
|
|
|
System.out.println(link.snippet());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|