From b21e9149f50ccd3dc4a831aa5f0f8ced51c8b471 Mon Sep 17 00:00:00 2001 From: orbiter Date: Wed, 10 Jun 2009 12:41:15 +0000 Subject: [PATCH] another fix for navigation results, the json result format and searches with yacyinteractive git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6041 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- htroot/yacyinteractive.html | 2 +- htroot/yacysearchtrailer.java | 58 ++++++++++++++++------------------- htroot/yacysearchtrailer.json | 2 +- 3 files changed, 29 insertions(+), 33 deletions(-) diff --git a/htroot/yacyinteractive.html b/htroot/yacyinteractive.html index f73469bbe..09649f164 100644 --- a/htroot/yacyinteractive.html +++ b/htroot/yacyinteractive.html @@ -19,7 +19,7 @@ function search(query) { else if (window.ActiveXObject) { // IE self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } - self.xmlHttpReq.open('GET', "yacysearch.json?verify=false&resource=local&maximumRecords=100&query=" + query, true); + self.xmlHttpReq.open('GET', "yacysearch.json?verify=false&resource=local&maximumRecords=100&nav=topics&query=" + query, true); self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); self.xmlHttpReq.onreadystatechange = function() { if (self.xmlHttpReq.readyState == 4) { diff --git a/htroot/yacysearchtrailer.java b/htroot/yacysearchtrailer.java index d13cb07a8..87e0fd903 100644 --- a/htroot/yacysearchtrailer.java +++ b/htroot/yacysearchtrailer.java @@ -39,7 +39,7 @@ import de.anomic.server.serverSwitch; public class yacysearchtrailer { - private static final int MAX_TOPWORDS = 24; + private static final int MAX_TOPWORDS = 10; public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch env) { final serverObjects prop = new serverObjects(); @@ -59,7 +59,7 @@ public class yacysearchtrailer { // host navigators ArrayList hostNavigator = theSearch.getHostNavigator(10); - if (hostNavigator == null) { + if (hostNavigator == null || hostNavigator.size() == 0) { prop.put("nav-domains", 0); } else { prop.put("nav-domains", 1); @@ -79,37 +79,9 @@ public class yacysearchtrailer { prop.put("nav-domains_element", hostNavigator.size()); } - // attach the bottom line with search references (topwords) - final ArrayList references = theSearch.getTopicNavigator(10); - // default settings for no topics - prop.put("nav-topics", "0"); - - if (references.size() > 0) { - int i = 0; - NavigatorEntry e; - Iterator iter = references.iterator(); - while (iter.hasNext()) { - e = iter.next(); - if (/*(theQuery == null) ||*/ (theQuery.queryString == null)) break; - if (e != null && e.name != null) { - prop.putHTML("nav-topics_element_" + i + "_name", e.name); - prop.put("nav-topics_element_" + i + "_url", "" + e.name + " (" + e.count + ")"); - prop.putJSON("nav-topics_element_" + i + "_url-json", plasmaSearchQuery.navurl("json", 0, display, theQuery, theQuery.urlMask, e.name, theQuery.navigators)); - prop.put("nav-topics_element_" + i + "_count", e.count); - prop.put("nav-topics_element_" + i + "_modifier", e.name); - prop.put("nav-topics_element_" + i + "_nl", (iter.hasNext() && i < MAX_TOPWORDS) ? 1 : 0); - } - if (i++ > MAX_TOPWORDS) { - break; - } - } - prop.put("nav-topics_element", i); - prop.put("nav-topics", "1"); - } - // author navigators ArrayList authorNavigator = theSearch.getAuthorNavigator(10); - if (authorNavigator == null) { + if (authorNavigator == null || authorNavigator.size() == 0) { prop.put("nav-authors", 0); } else { prop.put("nav-authors", 1); @@ -131,6 +103,30 @@ public class yacysearchtrailer { prop.put("nav-authors_element", authorNavigator.size()); } + // attach always the topics + ArrayList topicNavigator = theSearch.getTopicNavigator(10); + if (topicNavigator == null) topicNavigator = new ArrayList(); + int i = 0; + NavigatorEntry e; + Iterator iter = topicNavigator.iterator(); + while (iter.hasNext()) { + e = iter.next(); + if (/*(theQuery == null) ||*/ (theQuery.queryString == null)) break; + if (e != null && e.name != null) { + prop.putHTML("nav-topics_element_" + i + "_name", e.name); + prop.put("nav-topics_element_" + i + "_url", "" + e.name + " (" + e.count + ")"); + prop.putJSON("nav-topics_element_" + i + "_url-json", plasmaSearchQuery.navurl("json", 0, display, theQuery, theQuery.urlMask, e.name, theQuery.navigators)); + prop.put("nav-topics_element_" + i + "_count", e.count); + prop.put("nav-topics_element_" + i + "_modifier", e.name); + prop.put("nav-topics_element_" + i + "_nl", (iter.hasNext() && i < MAX_TOPWORDS) ? 1 : 0); + } + if (i++ > MAX_TOPWORDS) { + break; + } + } + prop.put("nav-topics_element", i); + prop.put("nav-topics", "1"); + serverProfiling.update("SEARCH", new plasmaProfiling.searchEvent(theQuery.id(true), plasmaSearchEvent.FINALIZATION + "-" + "bottomline", 0, 0), false); return prop; diff --git a/htroot/yacysearchtrailer.json b/htroot/yacysearchtrailer.json index 618792a88..65f394d9f 100644 --- a/htroot/yacysearchtrailer.json +++ b/htroot/yacysearchtrailer.json @@ -24,7 +24,7 @@ {"name": "#[name]#", "count": "#[count]#", "modifier": "#[modifier]#", "url": "#[url-json]#"}#(nl)#::,#(/nl)# #{/element}# ] - }#(/nav-authors)##(nav-topics)#:: + },#(/nav-authors)##(nav-topics)#:: { "facetname": "topics", "displayname": "Topics",