Permalink
Browse files

Activate hosts navigator plugin. This includes rwi results in the nav…

…igator

count.
This might be tangential related to http://mantis.tokeek.de/view.php?id=736
as the example includes a local index search, while rwi results are not
counted.
  • Loading branch information...
reger24 committed Apr 10, 2017
1 parent 05a1b14 commit 7b80189bda73b7118d996b4ff07681ac06cf5f60
@@ -156,14 +156,6 @@
}
}
</script>
#(nav-domains)#::
<ul class="nav nav-sidebar menugroup">
<li style="cursor: pointer; cursor: hand;"><h3 onclick="toggleVisibility('domains', #[count]#);">Provider [#[count]#] <span style="float:right" id="chevron-domains" class="glyphicon glyphicon-chevron-down" title="click to expand facet"></span></h3></li>
#{element}#
<li style="display:none" id="#[id]#"><a href="#[url]#" class="MenuItemLink"><input type="checkbox" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/> #[name]# (#[count]#)</a></li>
#{/element}#</ul>
<script>if (#[count]# <= 8) toggleVisibility('domains', #[count]#);</script>
#(/nav-domains)#
#(nav-languages)#::
<ul class="nav nav-sidebar menugroup">
@@ -103,47 +103,6 @@ public static serverObjects respond(final RequestHeader header, final serverObje
int count;
Iterator<String> navigatorIterator;
// domain navigators
final ScoreMap<String> hostNavigator = theSearch.hostNavigator;
if (hostNavigator == null || hostNavigator.isEmpty()) {
prop.put("nav-domains", 0);
} else {
prop.put("nav-domains", 1);
navigatorIterator = hostNavigator.keys(false);
int i = 0, pos = 0, neg = 0;
String nav, rawNav;
while (i < QueryParams.FACETS_STANDARD_MAXCOUNT && navigatorIterator.hasNext()) {
name = navigatorIterator.next();
count = hostNavigator.get(name);
if (count == 0) break;
nav = "site%3A" + name;
/* Avoid double percent encoding in QueryParams.navurl */
rawNav = "site:" + name;
if (theSearch.query.modifier.sitehost == null || !theSearch.query.modifier.sitehost.contains(name)) {
pos++;
prop.put("nav-domains_element_" + i + "_on", 1);
prop.put(fileType, "nav-domains_element_" + i + "_modifier", nav);
} else {
neg++;
prop.put("nav-domains_element_" + i + "_on", 0);
prop.put(fileType, "nav-domains_element_" + i + "_modifier", "-" + nav);
nav="";
rawNav = "";
}
prop.put(fileType, "nav-domains_element_" + i + "_name", name);
prop.put(fileType, "nav-domains_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, rawNav, false).toString());
prop.put(fileType, "nav-domains_element_" + i + "_id", "domains_" + i);
prop.put("nav-domains_element_" + i + "_count", count);
prop.put("nav-domains_element_" + i + "_nl", 1);
i++;
}
prop.put("nav-domains_element", i);
prop.put("nav-domains_count", i);
i--;
prop.put("nav-domains_element_" + i + "_nl", 0);
if (pos == 1 && neg == 0) prop.put("nav-domains", 0); // this navigation is not useful
}
// language navigators
final ScoreMap<String> languageNavigator = theSearch.languageNavigator;
if (languageNavigator == null || languageNavigator.isEmpty()) {
@@ -213,7 +172,6 @@ public static serverObjects respond(final RequestHeader header, final serverObje
for (Map.Entry<String, Integer> entry: cloud) {
name = entry.getKey();
count = entry.getValue();
prop.put("nav-topics_element_" + i + "_on", 1);
prop.put(fileType, "nav-topics_element_" + i + "_modifier", name);
prop.put(fileType, "nav-topics_element_" + i + "_name", name);
prop.put(fileType, "nav-topics_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, name, false).toString());
@@ -34,19 +34,7 @@
{"name": "#[name]#", "count": "#[count]#", "modifier": "#[modifier]#", "url": "#[url]#"}#(nl)#::,#(/nl)#
#{/element}#
]
},#(/nav-protocols)##(nav-domains)#::{
"facetname": "domains",
"displayname": "Domains",
"type": "String",
"min": "0",
"max": "0",
"mean": "0",
"elements": [
#{element}#
{"name": "#[name]#", "count": "#[count]#", "modifier": "#[modifier]#", "url": "#[url]#"}#(nl)#::,#(/nl)#
#{/element}#
]
},#(/nav-domains)##{navs}#{
},#(/nav-protocols)##{navs}#{
"facetname": "#[name]#",
"displayname": "#[displayname]#",
"type": "String",
@@ -1,11 +1,4 @@
<yacy:navigation>
#(nav-domains)#::
<yacy:facet name="domains" displayname="Domains" type="String" min="0" max="0" mean="0">
#{element}#
<yacy:element name="#[name]#" count="#[count]#" modifier="#[modifier]#" url="#[url]#"/>
#{/element}#
</yacy:facet>
#(/nav-domains)#
#{navs}#
<yacy:facet name="#[name]#" displayname="#[displayname]#" type="String" min="0" max="0" mean="0">
#{element}#
@@ -41,7 +41,7 @@
static public Map<String, String> listAvailable() {
Map<String, String> defaultnavplugins = new TreeMap<String, String>();
defaultnavplugins.put("filetype", "Filetype");
// defaultnavplugins.put("hosts", "Provider");
defaultnavplugins.put("hosts", "Provider");
// defaultnavplugins.put("language", "Language");
defaultnavplugins.put("authors", "Authors");
defaultnavplugins.put("collections", "Collection");
@@ -87,11 +87,11 @@
if (navname.contains("filetype")) {
navigatorPlugins.put("filetype", new FileTypeNavigator("Filetype", CollectionSchema.url_file_ext_s));
}
/*
if (navname.contains("hosts")) {
navigatorPlugins.put("hosts", new HostNavigator("Provider", CollectionSchema.host_s));
}
/*
if (navname.contains("language")) {
navigatorPlugins.put("language", new LanguageNavigator("Language"));
}
@@ -378,8 +378,8 @@ public static String parseFromToExpression(final String from, final String to, f
Date toDate = to == null || to.equals("*") ? null : DateDetection.parseLine(to, timezoneOffset);
StringBuilder filterQuery = new StringBuilder(20);
if (fromDate != null && toDate != null) {
String dstrFrom = fromDate == null ? "*" : DateFormatUtil.formatExternal(fromDate);
String dstrTo = toDate == null ? "*" : DateFormatUtil.formatExternal(toDate);
String dstrFrom = DateFormatUtil.formatExternal(fromDate);
String dstrTo = DateFormatUtil.formatExternal(toDate);
filterQuery.append(CollectionSchema.dates_in_content_dts.getSolrFieldName()).append(":[").append(dstrFrom).append(" TO ").append(dstrTo).append(']');
}
return filterQuery.toString();
@@ -146,7 +146,6 @@
private int localsolroffset;
private final AtomicInteger expectedRemoteReferences, maxExpectedRemoteReferences; // counter for referenced that had been sorted out for other reasons
public final ScoreMap<String> locationNavigator; // a counter for the appearance of location coordinates
public final ScoreMap<String> hostNavigator; // a counter for the appearance of host names
public final ScoreMap<String> protocolNavigator; // a counter for protocol types
public final ScoreMap<String> dateNavigator; // a counter for file types
public final ScoreMap<String> languageNavigator; // a counter for appearance of languages
@@ -262,7 +261,6 @@ protected SearchEvent(
// prepare configured search navigation
final String navcfg = Switchboard.getSwitchboard().getConfig("search.navigation", "");
this.locationNavigator = navcfg.contains("location") ? new ConcurrentScoreMap<String>() : null;
this.hostNavigator = navcfg.contains("hosts") ? new ConcurrentScoreMap<String>() : null;
this.protocolNavigator = navcfg.contains("protocol") ? new ConcurrentScoreMap<String>() : null;
this.dateNavigator = navcfg.contains("date") ? new ClusteredScoreMap<String>(true) : null;
this.topicNavigatorCount = navcfg.contains("topics") ? MAX_TOPWORDS : 0;
@@ -842,18 +840,6 @@ public void addNodes(
}
}
if (this.hostNavigator != null) {
fcts = facets.get(CollectionSchema.host_s.getSolrFieldName());
if (fcts != null) {
for (String host: fcts) {
int hc = fcts.get(host);
if (hc == 0) continue;
if (host.startsWith("www.")) host = host.substring(4);
this.hostNavigator.inc(host, hc);
}
}
}
if (this.dateNavigator != null) {
fcts = facets.get(CollectionSchema.dates_in_content_dts.getSolrFieldName());
if (fcts != null) this.dateNavigator.inc(fcts);
@@ -1340,6 +1326,11 @@ public long getSnippetComputationTime() {
return null;
}
/**
* Adds the retrieved results (fulltext & rwi) to the result list and
* computes the text snippets
* @return true on adding entries to resultlist otherwise false
*/
public boolean drainStacksToResult() {
// we take one entry from both stacks at the same time
boolean success = false;
@@ -1465,7 +1456,7 @@ private long postRanking(final URIMetadataNode rentry, final ScoreMap<String> to
if (this.query.getSegment().connectedCitation()) {
int referencesCount = this.query.getSegment().urlCitation().count(rentry.hash());
r += (128 * referencesCount / (1 + 2 * rentry.llocal() + rentry.lother())) << this.query.ranking.coeff_citation;
} /* else r += 0; */
}
// prefer hit with 'prefer' pattern
if (this.query.prefer.matcher(rentry.url().toNormalform(true)).matches()) r += 255 << this.query.ranking.coeff_prefer;
if (this.query.prefer.matcher(rentry.title()).matches()) r += 255 << this.query.ranking.coeff_prefer;
@@ -1482,11 +1473,11 @@ private long postRanking(final URIMetadataNode rentry, final ScoreMap<String> to
// (example Title="News News News News News News - today is party -- News News News News News News" to add one score instead of 12 * score !)
for (final String urlcomp : urlcompmap) {
int tc = topwords.get(urlcomp);
if (tc > 0) r += Math.max(1, tc) << this.query.ranking.coeff_urlcompintoplist;
if (tc > 0) r += tc << this.query.ranking.coeff_urlcompintoplist;
}
for (final String descrcomp : descrcompmap) {
int tc = topwords.get(descrcomp);
if (tc > 0) r += Math.max(1, tc) << this.query.ranking.coeff_descrcompintoplist;
if (tc > 0) r += tc << this.query.ranking.coeff_descrcompintoplist;
}
final Iterator<String> shi = this.query.getQueryGoal().getIncludeWords();
@@ -1553,6 +1544,14 @@ public URIMetadataNode getSnippet(URIMetadataNode page, final CacheStrategy cach
return page.makeResultEntry(this.query.getSegment(), this.peers, null); // result without snippet
}
/**
* This is the access point for the search interface to retrive ranked results.
* for display.
*
* @param item requested result counting number (starting at 0)
* @param timeout
* @return
*/
public URIMetadataNode oneResult(final int item, final long timeout) {
// check if we already retrieved this item
// (happens if a search pages is accessed a second time)

0 comments on commit 7b80189

Please sign in to comment.