From 8e3bd175546cdbd03a05365fe31399826a53bd9d Mon Sep 17 00:00:00 2001 From: orbiter Date: Thu, 21 Dec 2006 03:09:46 +0000 Subject: [PATCH] adopted DetailedSearch page to new ranking options - fixed bug http://www.yacy-forum.de/viewtopic.php?t=3265 - more attributes on page - attributes can be set as default for main search page - option to re-set the attributes to built-in values git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3109 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/DetailedSearch.html | 99 ++++++++----------- htroot/DetailedSearch.java | 63 ++++++++---- htroot/yacysearch.java | 3 +- .../plasma/plasmaSearchRankingProfile.java | 44 ++++----- source/de/anomic/yacy/yacyClient.java | 2 +- yacy.init | 7 ++ 6 files changed, 112 insertions(+), 106 deletions(-) diff --git a/htroot/DetailedSearch.html b/htroot/DetailedSearch.html index a72e607a3..93e041bc3 100644 --- a/htroot/DetailedSearch.html +++ b/htroot/DetailedSearch.html @@ -21,6 +21,12 @@ } document.write(n); } + function checkerline(descr, tag, dflt) { + document.write("
" + descr + "
"); + document.write("
"); + checkers(tag, dflt); + document.write("
"); + } /* ]]> */

Detailed Search

@@ -45,71 +51,47 @@
- Local Pre-Ranking + Pre-Ranking
-
Date
-
- -
-
YBR
-
- -
-
Position in Text
-
- -
-
Word Distance
-
- -
-
Word Hit Count
-
- -
-
Domain Length
-
- -
+ + + + + + + + + + + + + + + + + + + + + + + + +
- Local Post-Ranking + Post-Ranking
-
URL Length
-
- -
-
URL Components
-
- -
-
Description Length
-
- -
-
Description Components
-
- -
-
Query appears in URL
-
- -
-
Query appears in Description
-
- -
-
URL Component appears in Toplist
-
- -
-
Description Component appears in Toplist
-
- -
+ + +
+
+ + +
#(type)# #(excluded)# @@ -145,6 +127,7 @@ #{/results}# #(/type)# + #%env/templates/footer.template%# \ No newline at end of file diff --git a/htroot/DetailedSearch.java b/htroot/DetailedSearch.java index f80e4e8d1..a74ecbe48 100644 --- a/htroot/DetailedSearch.java +++ b/htroot/DetailedSearch.java @@ -59,38 +59,59 @@ import de.anomic.server.serverCore; import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; import de.anomic.yacy.yacyCore; +import de.anomic.tools.crypt; public class DetailedSearch { + private static serverObjects defaultValues() { + final serverObjects prop = new serverObjects(); + prop.put("search", ""); + prop.put("num-results", 0); + prop.put("excluded", 0); + prop.put("combine", 0); + prop.put("resultbottomline", 0); + prop.put("localCount", 10); + prop.put("localWDist", 999); + //prop.put("globalChecked", "checked"); + prop.put("globalChecked", ""); + prop.put("postsortChecked", "checked=\"checked\""); + prop.put("localTime", 6); + prop.put("results", ""); + prop.put("urlmaskoptions", 0); + prop.put("urlmaskoptions_urlmaskfilter", ".*"); + return prop; + } + public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) { final plasmaSwitchboard sb = (plasmaSwitchboard) env; // case if no values are requested if (post == null || env == null) { // we create empty entries for template strings - final serverObjects prop = new serverObjects(); - prop.put("promoteSearchPageGreeting", env.getConfig("promoteSearchPageGreeting", "")); - prop.put("search", ""); - prop.put("num-results", 0); - prop.put("excluded", 0); - prop.put("combine", 0); - prop.put("resultbottomline", 0); - prop.put("localCount", 10); - prop.put("localWDist", 999); - //prop.put("globalChecked", "checked"); - prop.put("globalChecked", ""); - prop.put("postsortChecked", "checked=\"checked\""); - prop.put("localTime", 6); - prop.put("results", ""); - prop.put("urlmaskoptions", 0); - prop.put("urlmaskoptions_urlmaskfilter", ".*"); - String defaultRankingProfile = new plasmaSearchRankingProfile("text").toExternalString(); - prop.putAll(new plasmaSearchRankingProfile("", defaultRankingProfile).toExternalMap("local")); + final serverObjects prop = defaultValues(); + plasmaSearchRankingProfile ranking = (sb.getConfig("rankingProfile", "").length() == 0) ? new plasmaSearchRankingProfile("text") : new plasmaSearchRankingProfile("", crypt.simpleDecode(sb.getConfig("rankingProfile", ""), null)); + prop.putAll(ranking.toExternalMap("local")); return prop; } - - boolean global = (post == null) ? false : post.get("global", "").equals("on"); - boolean postsort = (post == null) ? false : post.get("postsort", "").equals("on"); + + if (post.containsKey("EnterRanking")) { + plasmaSearchRankingProfile ranking = new plasmaSearchRankingProfile("local", post.toString()); + sb.setConfig("rankingProfile", crypt.simpleEncode(ranking.toExternalString())); + final serverObjects prop = defaultValues(); + prop.putAll(ranking.toExternalMap("local")); + return prop; + } + + if (post.containsKey("ResetRanking")) { + sb.setConfig("rankingProfile", ""); + plasmaSearchRankingProfile ranking = new plasmaSearchRankingProfile("text"); + final serverObjects prop = defaultValues(); + prop.putAll(ranking.toExternalMap("local")); + return prop; + } + + boolean global = post.get("global", "").equals("on"); + boolean postsort = post.get("postsort", "").equals("on"); final boolean indexDistributeGranted = sb.getConfig("allowDistributeIndex", "true").equals("true"); final boolean indexReceiveGranted = sb.getConfig("allowReceiveIndex", "true").equals("true"); if (!indexDistributeGranted || !indexReceiveGranted) { global = false; } diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java index 40e24e379..685b67ab9 100644 --- a/htroot/yacysearch.java +++ b/htroot/yacysearch.java @@ -71,6 +71,7 @@ import de.anomic.server.serverCore; import de.anomic.server.serverDate; import de.anomic.server.serverObjects; import de.anomic.server.serverSwitch; +import de.anomic.tools.crypt; import de.anomic.yacy.yacyCore; import de.anomic.yacy.yacyNewsRecord; @@ -253,7 +254,7 @@ public class yacysearch { "", 20, constraint); - plasmaSearchRankingProfile ranking = new plasmaSearchRankingProfile(contentdomString); + plasmaSearchRankingProfile ranking = (sb.getConfig("rankingProfile", "").length() == 0) ? new plasmaSearchRankingProfile(contentdomString) : new plasmaSearchRankingProfile("", crypt.simpleDecode(sb.getConfig("rankingProfile", ""), null)); plasmaSearchTimingProfile localTiming = new plasmaSearchTimingProfile(4 * thisSearch.maximumTime / 10, thisSearch.wantedResults); plasmaSearchTimingProfile remoteTiming = new plasmaSearchTimingProfile(6 * thisSearch.maximumTime / 10, thisSearch.wantedResults); prop = sb.searchFromLocal(thisSearch, ranking, localTiming, remoteTiming, true); diff --git a/source/de/anomic/plasma/plasmaSearchRankingProfile.java b/source/de/anomic/plasma/plasmaSearchRankingProfile.java index bb49c9c0d..95119a2a0 100644 --- a/source/de/anomic/plasma/plasmaSearchRankingProfile.java +++ b/source/de/anomic/plasma/plasmaSearchRankingProfile.java @@ -82,8 +82,6 @@ public class plasmaSearchRankingProfile { public static final String CATHASAPP = "cathasapp"; // post-sort predicates - public static final String QUERYINURL = "queryinurl"; - public static final String QUERYINDESCR = "queryindescr"; public static final String URLCOMPINTOPLIST = "urlcompintoplist"; public static final String DESCRCOMPINTOPLIST = "descrcompintoplist"; public static final String PREFER = "prefer"; @@ -94,7 +92,7 @@ public class plasmaSearchRankingProfile { coeff_posintext, coeff_posofphrase, coeff_worddistance, coeff_appurl, coeff_appdescr, coeff_appauthor, coeff_apptags, coeff_appref, coeff_appemph, coeff_catindexof, coeff_cathasimage, coeff_cathasaudio, coeff_cathasvideo, coeff_cathasapp, - coeff_queryinurl, coeff_queryindescr, coeff_urlcompintoplist, coeff_descrcompintoplist, coeff_prefer; + coeff_urlcompintoplist, coeff_descrcompintoplist, coeff_prefer; public plasmaSearchRankingProfile(String mediatype) { // set default-values @@ -119,16 +117,14 @@ public class plasmaSearchRankingProfile { coeff_apptags = 8; coeff_appref = 9; coeff_appemph = 11; - coeff_queryinurl = 12; - coeff_queryindescr = 8; coeff_urlcompintoplist = 3; coeff_descrcompintoplist = 2; coeff_prefer = 15; - coeff_catindexof = (mediatype.equals("text")) ? 0 : 10; - coeff_cathasimage = (mediatype.equals("image")) ? 15 : 0; - coeff_cathasaudio = (mediatype.equals("audio")) ? 15 : 0; - coeff_cathasvideo = (mediatype.equals("video")) ? 15 : 0; - coeff_cathasapp = (mediatype.equals("app")) ? 15 : 0; + coeff_catindexof = (mediatype.equals("text")) ? 1 : 10; + coeff_cathasimage = (mediatype.equals("image")) ? 15 : 1; + coeff_cathasaudio = (mediatype.equals("audio")) ? 15 : 1; + coeff_cathasvideo = (mediatype.equals("video")) ? 15 : 1; + coeff_cathasapp = (mediatype.equals("app")) ? 15 : 1; } public plasmaSearchRankingProfile(String prefix, String profile) { @@ -140,10 +136,12 @@ public class plasmaSearchRankingProfile { int p; int s = (prefix == null) ? 0 : prefix.length(); String e; + for (int i = 0; i < elts.length; i++) { e = elts[i].trim(); if ((s == 0) || (e.startsWith(prefix))) { - coeff.put(e.substring(s, (p = e.indexOf("="))), new Integer(Integer.parseInt(e.substring(p + 1)))); + p = e.indexOf("="); + if (e.length() > p + 1) coeff.put(e.substring(s, p), new Integer(Integer.parseInt(e.substring(p + 1)))); } } coeff_domlength = parseMap(coeff, DOMLENGTH, coeff_domlength); @@ -166,13 +164,11 @@ public class plasmaSearchRankingProfile { coeff_apptags = parseMap(coeff, APPTAGS, coeff_apptags); coeff_appref = parseMap(coeff, APPREF, coeff_appref); coeff_appemph = parseMap(coeff, APPEMPH, coeff_appemph); - coeff_catindexof = parseMap(coeff, APPEMPH, coeff_catindexof); - coeff_cathasimage = parseMap(coeff, APPEMPH, coeff_cathasimage); - coeff_cathasaudio = parseMap(coeff, APPEMPH, coeff_cathasaudio); - coeff_cathasvideo = parseMap(coeff, APPEMPH, coeff_cathasvideo); - coeff_cathasapp = parseMap(coeff, APPEMPH, coeff_cathasapp); - coeff_queryinurl = parseMap(coeff, QUERYINURL, coeff_queryinurl); - coeff_queryindescr = parseMap(coeff, QUERYINDESCR, coeff_queryindescr); + coeff_catindexof = parseMap(coeff, CATINDEXOF, coeff_catindexof); + coeff_cathasimage = parseMap(coeff, CATHASIMAGE, coeff_cathasimage); + coeff_cathasaudio = parseMap(coeff, CATHASAUDIO, coeff_cathasaudio); + coeff_cathasvideo = parseMap(coeff, CATHASVIDEO, coeff_cathasvideo); + coeff_cathasapp = parseMap(coeff, CATHASAPP, coeff_cathasapp); coeff_urlcompintoplist = parseMap(coeff, URLCOMPINTOPLIST, coeff_urlcompintoplist); coeff_descrcompintoplist = parseMap(coeff, DESCRCOMPINTOPLIST, coeff_descrcompintoplist); coeff_prefer = parseMap(coeff, PREFER, coeff_prefer); @@ -181,7 +177,7 @@ public class plasmaSearchRankingProfile { private static int parseMap(HashMap coeff, String attr, int dflt) { if (coeff.containsKey(attr)) try { - return Integer.parseInt((String) coeff.get(attr)); + return ((Integer) coeff.get(attr)).intValue(); } catch (NumberFormatException e) { return dflt; } else { @@ -220,8 +216,6 @@ public class plasmaSearchRankingProfile { ext.put(prefix + CATHASAUDIO, Integer.toString(coeff_cathasaudio)); ext.put(prefix + CATHASVIDEO, Integer.toString(coeff_cathasvideo)); ext.put(prefix + CATHASAPP, Integer.toString(coeff_cathasapp)); - ext.put(prefix + QUERYINURL, Integer.toString(coeff_queryinurl)); - ext.put(prefix + QUERYINDESCR, Integer.toString(coeff_queryindescr)); ext.put(prefix + URLCOMPINTOPLIST, Integer.toString(coeff_urlcompintoplist)); ext.put(prefix + DESCRCOMPINTOPLIST, Integer.toString(coeff_descrcompintoplist)); ext.put(prefix + PREFER, Integer.toString(coeff_prefer)); @@ -258,7 +252,7 @@ public class plasmaSearchRankingProfile { ranking += (normalizedEntry.urlcomps() == 0) ? 0 : (256 - normalizedEntry.urlcomps()) << coeff_urlcomps; ranking += (normalizedEntry.hitcount() == 0) ? 0 : normalizedEntry.hitcount() << coeff_hitcount; ranking += (normalizedEntry.posintext() == 0) ? 0 : (256 - normalizedEntry.posintext()) << coeff_posintext; - ranking += (normalizedEntry.posofphrase() == 0) ? 0 : (256 - normalizedEntry.hitcount()) << coeff_posofphrase; + ranking += (normalizedEntry.posofphrase() == 0) ? 0 : (256 - normalizedEntry.posofphrase()) << coeff_posofphrase; ranking += (normalizedEntry.worddistance() == 0) ? 0 : (256 - normalizedEntry.worddistance()) << coeff_worddistance; kelondroBitfield flags = normalizedEntry.flags(); @@ -275,7 +269,7 @@ public class plasmaSearchRankingProfile { ranking += (flags.get(plasmaCondenser.flag_cat_hasapp)) ? 256 << coeff_cathasapp : 0; ranking += (plasmaURL.probablyRootURL(normalizedEntry.urlHash())) ? 16 << coeff_urllength : 0; - ranking += (plasmaURL.probablyWordURL(normalizedEntry.urlHash(), searchedWord) != null) ? 256 << coeff_queryinurl : 0; + ranking += (plasmaURL.probablyWordURL(normalizedEntry.urlHash(), searchedWord) != null) ? 256 << coeff_appurl : 0; /* if (indexURL.probablyWordURL(normalizedEntry.urlHash(), searchedWord)) @@ -320,8 +314,8 @@ public class plasmaSearchRankingProfile { String queryhash; while (shi.hasNext()) { queryhash = (String) shi.next(); - if (urlcomph.contains(queryhash)) ranking += 256 << coeff_queryinurl; - if (descrcomph.contains(queryhash)) ranking += 256 << coeff_queryindescr; + if (urlcomph.contains(queryhash)) ranking += 256 << coeff_appurl; + if (descrcomph.contains(queryhash)) ranking += 256 << coeff_appdescr; } return ranking; diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.java index 06880ea83..3066ba349 100644 --- a/source/de/anomic/yacy/yacyClient.java +++ b/source/de/anomic/yacy/yacyClient.java @@ -464,7 +464,7 @@ public final class yacyClient { } if (result.size() == 0) { - yacyCore.log.logFine("SEARCH failed FROM " + targetPeer.hash + ":" + targetPeer.getName() + " (zero response), score=" + targetPeer.selectscore + ", DHTdist=" + yacyDHTAction.dhtDistance(targetPeer.hash, wordhashes)); + yacyCore.log.logFine("SEARCH failed FROM " + targetPeer.hash + ":" + targetPeer.getName() + " (zero response), score=" + targetPeer.selectscore + ", DHTdist=" + yacyDHTAction.dhtDistance(targetPeer.hash, wordhashes.substring(0, 12))); return null; } diff --git a/yacy.init b/yacy.init index 6aea2da14..d964ea011 100644 --- a/yacy.init +++ b/yacy.init @@ -852,3 +852,10 @@ soap.serviceDeploymentList = # all - everybody has write right # user - the admin and every user registered in the user db has write right WikiAccess = admin + +# Search Profiles +# we will support different search profiles +# this is currently only a single default profile +# If this profile setting is empty, a hard-coded profile from plasmaSearchRanking is used +rankingProfile = +