some kind of refactoring of yacysearch:

made 'room' for new picture search result presentation

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1993 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
orbiter 2006-04-03 22:47:59 +00:00
parent 6b63e26cbb
commit e2e8d0c188
5 changed files with 90 additions and 129 deletions

View File

@ -57,6 +57,7 @@ picPlus.src = "/env/grafics/plus.gif";
document.searchform.Enter.value = "search again - catch up more links";
</SCRIPT>
#(type)#
<p>
#(excluded)#
::
@ -133,8 +134,12 @@ To do this, press this button:
You can enrich the search results by using the 'global' option; you must also switch to online mode
(by using the proxy) to contribute to the global index.
#(/resultbottomline)#
</p><br>
<hr>
</p>
::
xxx
#(/type)#
<br><hr>
<center><i>YaCy is a GPL'ed project
with the target of implementing a P2P-based global search engine.<br>
Architecture (C) by Michael Peter Christen,

View File

@ -100,37 +100,18 @@ public class yacysearch {
// we create empty entries for template strings
final serverObjects prop = new serverObjects();
prop.put("promoteSearchPageGreeting", env.getConfig("promoteSearchPageGreeting", ""));
prop.put("former", "");
prop.put("num-results", 0);
prop.put("excluded", 0);
prop.put("combine", 0);
prop.put("resultbottomline", 0);
prop.put("count-10", 1);
prop.put("count-50", 0);
prop.put("count-100", 0);
prop.put("count-1000", 0);
prop.put("count", 10);
prop.put("order-ybr-date-quality", plasmaSearchPreOrder.canUseYBR() ? 1 : 0);
prop.put("order-ybr-quality-date", 0);
prop.put("order-date-ybr-quality", 0);
prop.put("order-quality-ybr-date", 0);
prop.put("order-date-quality-ybr", plasmaSearchPreOrder.canUseYBR() ? 0 : 1);
prop.put("order-quality-date-ybr", 0);
prop.put("order", plasmaSearchPreOrder.canUseYBR() ? "YBR-Date-Quality" : "Date-Quality-YBR");
prop.put("resource-global", ((global) ? 1 : 0));
prop.put("resource-local", ((global) ? 0 : 1));
prop.put("resource", "global");
prop.put("time-1", 0);
prop.put("time-3", 0);
prop.put("time-6", 1);
prop.put("time-10", 0);
prop.put("time-30", 0);
prop.put("time-60", 0);
prop.put("time", 6);
prop.put("results", "");
prop.put("urlmaskoptions", 0);
prop.put("urlmaskoptions_urlmaskfilter", ".*");
prop.put("urlmaskfilter", ".*");
prop.put("type", 0);
prop.put("type_excluded", 0);
prop.put("type_num-results", 0);
prop.put("type_combine", 0);
prop.put("type_resultbottomline", 0);
prop.put("type_results", "");
return prop;
}
@ -204,35 +185,37 @@ public class yacysearch {
*/
// remember the last search expression
env.setConfig("last-search", querystring);
// process result of search
prop.put("resultbottomline", 0);
prop.put("type", 0); // set type of result: normal link list
prop.put("type_resultbottomline", 0);
if (filtered.size() > 0) {
prop.put("excluded", 1);
prop.put("excluded_stopwords", filtered.toString());
prop.put("type_excluded", 1);
prop.put("type_excluded_stopwords", filtered.toString());
} else {
prop.put("excluded", 0);
prop.put("type_excluded", 0);
}
if (prop == null || prop.size() == 0) {
if (post.get("search", "").length() < 3) {
prop.put("num-results", 2); // no results - at least 3 chars
prop.put("type_num-results", 2); // no results - at least 3 chars
} else {
prop.put("num-results", 1); //no results
prop.put("type_num-results", 1); //no results
}
} else {
final int linkcount = Integer.parseInt(prop.get("linkcount", "0"));
final int orderedcount = Integer.parseInt(prop.get("orderedcount", "0"));
final int totalcount = Integer.parseInt(prop.get("totalcount", "0"));
final int linkcount = Integer.parseInt(prop.get("type_linkcount", "0"));
final int orderedcount = Integer.parseInt(prop.get("type_orderedcount", "0"));
final int totalcount = Integer.parseInt(prop.get("type_totalcount", "0"));
if (totalcount > 10) {
final Object[] references = (Object[]) prop.get("references", new String[0]);
prop.put("num-results", 4);
prop.put("num-results_linkcount", linkcount);
prop.put("num-results_orderedcount", orderedcount);
prop.put("num-results_totalcount", totalcount);
final Object[] references = (Object[]) prop.get("type_references", new String[0]);
prop.put("type_num-results", 4);
prop.put("type_num-results_linkcount", linkcount);
prop.put("type_num-results_orderedcount", orderedcount);
prop.put("type_num-results_totalcount", totalcount);
int hintcount = references.length;
if (hintcount > 0) {
prop.put("combine", 1);
prop.put("type_combine", 1);
// get the topwords
final TreeSet topwords = new TreeSet(kelondroNaturalOrder.naturalOrder);
@ -254,91 +237,58 @@ public class yacysearch {
while (iter.hasNext()) {
word = (String) iter.next();
if (word != null) {
prop.put("combine_words_" + hintcount + "_word", word);
prop.put("combine_words_" + hintcount + "_newsearch", post.get("search", "").replace(' ', '+') + "+" + word);
prop.put("combine_words_" + hintcount + "_count", count);
prop.put("combine_words_" + hintcount + "_order", order);
prop.put("combine_words_" + hintcount + "_resource", ((global) ? "global" : "local"));
prop.put("combine_words_" + hintcount + "_time", (searchtime / 1000));
prop.put("type_combine_words_" + hintcount + "_word", word);
prop.put("type_combine_words_" + hintcount + "_newsearch", post.get("search", "").replace(' ', '+') + "+" + word);
prop.put("type_combine_words_" + hintcount + "_count", count);
prop.put("type_combine_words_" + hintcount + "_order", order);
prop.put("type_combine_words_" + hintcount + "_resource", ((global) ? "global" : "local"));
prop.put("type_combine_words_" + hintcount + "_time", (searchtime / 1000));
}
prop.put("combine_words", hintcount);
prop.put("type_combine_words", hintcount);
if (hintcount++ > MAX_TOPWORDS) { break; }
}
}
} else {
if (totalcount == 0) {
prop.put("num-results", 3); // long
prop.put("type_num-results", 3); // long
} else {
prop.put("num-results", 4);
prop.put("num-results_linkcount", linkcount);
prop.put("num-results_orderedcount", orderedcount);
prop.put("num-results_totalcount", totalcount);
prop.put("type_num-results", 4);
prop.put("type_num-results_linkcount", linkcount);
prop.put("type_num-results_orderedcount", orderedcount);
prop.put("type_num-results_totalcount", totalcount);
}
}
}
if (urlmask.equals(".*")) {
prop.put("urlmaskoptions", 0);
} else {
prop.put("urlmaskoptions", 1);
}
prop.put("urlmaskfilter", urlmask);
prop.put("urlmaskoptions_urlmaskfilter", urlmask);
if (yacyonline) {
if (global) {
prop.put("resultbottomline", 1);
prop.put("resultbottomline_globalresults", prop.get("globalresults", "0"));
prop.put("type_resultbottomline", 1);
prop.put("type_resultbottomline_globalresults", prop.get("type_globalresults", "0"));
} else {
prop.put("resultbottomline", 2);
prop.put("type_resultbottomline", 2);
}
} else {
if (global) {
prop.put("resultbottomlien", 3);
prop.put("type_resultbottomlien", 3);
} else {
prop.put("resultbottomline", 4);
prop.put("type_resultbottomline", 4);
}
}
prop.put("count-10", ((count == 10)) ? 1 : 0);
prop.put("count-50", ((count == 50)) ? 1 : 0);
prop.put("count-100", ((count == 100)) ? 1 : 0);
prop.put("count-1000", ((count == 1000)) ? 1 : 0);
prop.put("count", count);
prop.put("order-ybr-date-quality", ((order.equals("YBR-Date-Quality")) ? 1 : 0));
prop.put("order-ybr-quality-date", ((order.equals("YBR-Quality-Date")) ? 1 : 0));
prop.put("order-date-ybr-quality", ((order.equals("Date-YBR-Quality")) ? 1 : 0));
prop.put("order-quality-ybr-date", ((order.equals("Quality-YBR-Date")) ? 1 : 0));
prop.put("order-date-quality-ybr", ((order.equals("Date-Quality-YBR")) ? 1 : 0));
prop.put("order-quality-date-ybr", ((order.equals("Quality-Date-YBR")) ? 1 : 0));
prop.put("resource-global", ((global) ? 1 : 0));
prop.put("resource-local", ((global) ? 0 : 1));
prop.put("resource", (global) ? "global" : "local");
prop.put("time-1", ((searchtime == 1000) ? 1 : 0));
prop.put("time-3", ((searchtime == 3000) ? 1 : 0));
prop.put("time-6", ((searchtime == 6000) ? 1 : 0));
prop.put("time-10", ((searchtime == 10000) ? 1 : 0));
prop.put("time-30", ((searchtime == 30000) ? 1 : 0));
prop.put("time-60", ((searchtime == 60000) ? 1 : 0));
prop.put("time", searchtime / 1000);
prop.put("former", post.get("search", ""));
prop.put("count", count);
prop.put("order", order);
// 'enrich search' variables
prop.put("num-results_former", post.get("search", ""));
prop.put("num-results_time", searchtime / 1000);
prop.put("num-results_count", count);
prop.put("num-results_resource", (global) ? "global" : "local");
prop.put("num-results_order", order);
// return rewrite properties
prop.put("promoteSearchPageGreeting", env.getConfig("promoteSearchPageGreeting", ""));
prop.put("resource", (global) ? "global" : "local");
prop.put("time", searchtime / 1000);
prop.put("urlmaskfilter", urlmask);
// adding some additional properties needed for the rss feed
String hostName = (String) header.get("Host","localhost");
if (hostName.indexOf(":") == -1) hostName += ":" + serverCore.getPortNr(env.getConfig("port", "8080"));
prop.put("rssYacyImageURL", "http://" + hostName + "/env/grafics/yacy.gif");
// return rewrite properties
return prop;
}

View File

@ -8,6 +8,7 @@
<url>#[rssYacyImageURL]#</url>
<title>Search for #[former]#</title>
</image>
#(type)#
#{results}#
<item>
<title>#[description]#</title>
@ -16,7 +17,7 @@
<pubDate>#[date]#</pubDate>
</item>
#{/results}#
<yacyTopwords:topwords>
<yacyTopwords:topwords>
#(combine)#
::
#{words}#
@ -26,5 +27,7 @@
#{/words}#
#(/combine)#
</yacyTopwords:topwords>
::
#(/type)#
</channel>
</rss>

View File

@ -4,6 +4,7 @@
<title>Search for #[former]#</title>
<description>Search for #[former]#</description>
#(type)#
<totalResultCount>#[totalcount]#</totalResultCount>
<currentResultCount>#[linkcount]#</currentResultCount>
@ -22,5 +23,7 @@
<size>#[size]#</size>
</yacySearchResultItem>
#{/results}#
::
#(/type)#
</yacySearchResult>
</yacySearch>

View File

@ -161,8 +161,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
public static int maxCRLDump = 500000;
public static int maxCRGDump = 200000;
private int dhtTransferIndexCount = 150;
private int dhtTransferIndexCount = 50;
private static final int dhtTransferIndexMinimum = 30;
// couloured list management
public static TreeSet badwords = null;
@ -1805,13 +1805,13 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
// result is a List of urlEntry elements: prepare answer
if (acc == null) {
prop.put("totalcount", "0");
prop.put("orderedcount", "0");
prop.put("linkcount", "0");
prop.put("type_totalcount", "0");
prop.put("type_orderedcount", "0");
prop.put("type_linkcount", "0");
} else {
prop.put("globalresults", acc.globalContributions);
prop.put("totalcount", acc.globalContributions + acc.localContributions);
prop.put("orderedcount", Integer.toString(acc.sizeOrdered()));
prop.put("type_totalcount", acc.globalContributions + acc.localContributions);
prop.put("type_orderedcount", Integer.toString(acc.sizeOrdered()));
prop.put("type_globalresults", acc.globalContributions);
int i = 0;
int p;
URL url;
@ -1866,23 +1866,23 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
if (snippet.getSource() == plasmaSnippetCache.ERROR_NO_MATCH) {
// suppress line: there is no match in that resource
} else {
prop.put("results_" + i + "_delete", "/yacysearch.html?search=" + formerSearch + "&Enter=Search&count=" + query.wantedResults + "&order=" + ranking.orderString() + "&resource=local&time=3&deleteref=" + urlhash + "&urlmaskfilter=.*");
prop.put("results_" + i + "_description", descr);
prop.put("results_" + i + "_url", urlstring);
prop.put("results_" + i + "_urlhash", urlhash);
prop.put("results_" + i + "_urlhexhash", yacySeed.b64Hash2hexHash(urlhash));
prop.put("results_" + i + "_urlname", nxTools.cutUrlText(urlname, 120));
prop.put("results_" + i + "_date", dateString(urlentry.moddate()));
prop.put("results_" + i + "_ybr", plasmaSearchPreOrder.ybr(urlentry.hash()));
prop.put("results_" + i + "_size", Long.toString(urlentry.size()));
prop.put("results_" + i + "_words",URLEncoder.encode(query.queryWords.toString(),"UTF-8"));
prop.put("type_results_" + i + "_delete", "/yacysearch.html?search=" + formerSearch + "&Enter=Search&count=" + query.wantedResults + "&order=" + ranking.orderString() + "&resource=local&time=3&deleteref=" + urlhash + "&urlmaskfilter=.*");
prop.put("type_results_" + i + "_description", descr);
prop.put("type_results_" + i + "_url", urlstring);
prop.put("type_results_" + i + "_urlhash", urlhash);
prop.put("type_results_" + i + "_urlhexhash", yacySeed.b64Hash2hexHash(urlhash));
prop.put("type_results_" + i + "_urlname", nxTools.cutUrlText(urlname, 120));
prop.put("type_results_" + i + "_date", dateString(urlentry.moddate()));
prop.put("type_results_" + i + "_ybr", plasmaSearchPreOrder.ybr(urlentry.hash()));
prop.put("type_results_" + i + "_size", Long.toString(urlentry.size()));
prop.put("type_results_" + i + "_words",URLEncoder.encode(query.queryWords.toString(),"UTF-8"));
// adding snippet if available
if (snippet.exists()) {
prop.put("results_" + i + "_snippet", 1);
prop.put("results_" + i + "_snippet_text", snippet.getLineMarked(query.queryHashes));
prop.put("type_results_" + i + "_snippet", 1);
prop.put("type_results_" + i + "_snippet_text", snippet.getLineMarked(query.queryHashes));
} else {
prop.put("results_" + i + "_snippet", 0);
prop.put("results_" + i + "_snippet_text", "");
prop.put("type_results_" + i + "_snippet", 0);
prop.put("type_results_" + i + "_snippet_text", "");
}
i++;
}
@ -1912,16 +1912,16 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
for (int ii = 0; ii < ws.length; ii++) System.out.print(ws[ii] + ", ");
System.out.println(" all words = " + ref.getElementCount() + ", total count = " + ref.getTotalCount());
*/
prop.put("references", ws);
prop.put("linkcount", Integer.toString(i));
prop.put("results", Integer.toString(i));
prop.put("type_references", ws);
prop.put("type_linkcount", Integer.toString(i));
prop.put("type_results", Integer.toString(i));
}
// log
log.logInfo("EXIT WORD SEARCH: " + query.queryWords + " - " +
prop.get("totalcount", "0") + " links found, " +
prop.get("orderedcount", "0") + " links ordered, " +
prop.get("linkcount", "?") + " links selected, " +
prop.get("type_totalcount", "0") + " links found, " +
prop.get("type_orderedcount", "0") + " links ordered, " +
prop.get("type_linkcount", "?") + " links selected, " +
((System.currentTimeMillis() - timestamp) / 1000) + " seconds");
return prop;
} catch (IOException e) {
@ -2115,7 +2115,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
} else {
dhtTransferIndexCount++;
}
if (dhtTransferIndexCount < 50) dhtTransferIndexCount = 50;
if (dhtTransferIndexCount < dhtTransferIndexMinimum) dhtTransferIndexCount = dhtTransferIndexMinimum;
// show success
return true;