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
pull/1/head
orbiter 16 years ago
parent 15c5406b9c
commit b21e9149f5

@ -19,7 +19,7 @@ function search(query) {
else if (window.ActiveXObject) { // IE else if (window.ActiveXObject) { // IE
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); 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.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() { self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) { if (self.xmlHttpReq.readyState == 4) {

@ -39,7 +39,7 @@ import de.anomic.server.serverSwitch;
public class yacysearchtrailer { 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) { public static serverObjects respond(final httpRequestHeader header, final serverObjects post, final serverSwitch<?> env) {
final serverObjects prop = new serverObjects(); final serverObjects prop = new serverObjects();
@ -59,7 +59,7 @@ public class yacysearchtrailer {
// host navigators // host navigators
ArrayList<NavigatorEntry> hostNavigator = theSearch.getHostNavigator(10); ArrayList<NavigatorEntry> hostNavigator = theSearch.getHostNavigator(10);
if (hostNavigator == null) { if (hostNavigator == null || hostNavigator.size() == 0) {
prop.put("nav-domains", 0); prop.put("nav-domains", 0);
} else { } else {
prop.put("nav-domains", 1); prop.put("nav-domains", 1);
@ -79,37 +79,9 @@ public class yacysearchtrailer {
prop.put("nav-domains_element", hostNavigator.size()); prop.put("nav-domains_element", hostNavigator.size());
} }
// attach the bottom line with search references (topwords)
final ArrayList<NavigatorEntry> references = theSearch.getTopicNavigator(10);
// default settings for no topics
prop.put("nav-topics", "0");
if (references.size() > 0) {
int i = 0;
NavigatorEntry e;
Iterator<NavigatorEntry> 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", "<a href=\"" + plasmaSearchQuery.navurl("html", 0, display, theQuery, theQuery.urlMask, e.name, theQuery.navigators) + "\">" + e.name + " (" + e.count + ")</a>");
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 // author navigators
ArrayList<NavigatorEntry> authorNavigator = theSearch.getAuthorNavigator(10); ArrayList<NavigatorEntry> authorNavigator = theSearch.getAuthorNavigator(10);
if (authorNavigator == null) { if (authorNavigator == null || authorNavigator.size() == 0) {
prop.put("nav-authors", 0); prop.put("nav-authors", 0);
} else { } else {
prop.put("nav-authors", 1); prop.put("nav-authors", 1);
@ -131,6 +103,30 @@ public class yacysearchtrailer {
prop.put("nav-authors_element", authorNavigator.size()); prop.put("nav-authors_element", authorNavigator.size());
} }
// attach always the topics
ArrayList<NavigatorEntry> topicNavigator = theSearch.getTopicNavigator(10);
if (topicNavigator == null) topicNavigator = new ArrayList<NavigatorEntry>();
int i = 0;
NavigatorEntry e;
Iterator<NavigatorEntry> 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", "<a href=\"" + plasmaSearchQuery.navurl("html", 0, display, theQuery, theQuery.urlMask, e.name, theQuery.navigators) + "\">" + e.name + " (" + e.count + ")</a>");
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); serverProfiling.update("SEARCH", new plasmaProfiling.searchEvent(theQuery.id(true), plasmaSearchEvent.FINALIZATION + "-" + "bottomline", 0, 0), false);
return prop; return prop;

@ -24,7 +24,7 @@
{"name": "#[name]#", "count": "#[count]#", "modifier": "#[modifier]#", "url": "#[url-json]#"}#(nl)#::,#(/nl)# {"name": "#[name]#", "count": "#[count]#", "modifier": "#[modifier]#", "url": "#[url-json]#"}#(nl)#::,#(/nl)#
#{/element}# #{/element}#
] ]
}#(/nav-authors)##(nav-topics)#:: },#(/nav-authors)##(nav-topics)#::
{ {
"facetname": "topics", "facetname": "topics",
"displayname": "Topics", "displayname": "Topics",

Loading…
Cancel
Save