Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
Adjust and move Language Navigator to be member of the navigatior plugin list.
reger87077b8fb600
diff --git a/htroot/ConfigSearchPage_p.html b/htroot/ConfigSearchPage_p.htmlindex 6cdd7d701..362da8b0f 100644--- a/htroot/ConfigSearchPage_p.html+++ b/htroot/ConfigSearchPage_p.html@@ -136,12 +136,6 @@</li>#(/search.navigation.location)#</ul></td></tr>- <tr>- <td><input type="checkbox" aria-labelledby="languageTitle" name="search.navigation.language" value="true" #(search.navigation.language)#::checked="checked" #(/search.navigation.language)# /></td>- <td><ul class="nav nav-sidebar menugroup" id="sidebarLanguages" style="padding-left:15px; padding-right:10px;">- <li><h3 id="languageTitle">Language</h3></li>- </ul></td>- </tr>#{search.navigation.plugin}#<tr><td><button class="btn btn-xs" title="Delete navigator" aria-label="Delete navigator" aria-describedby="title-#[name]#" name="del.nav" value="#[name]#"><span class="glyphicon glyphicon-remove" style="color: red"></span></button></td>diff --git a/htroot/ConfigSearchPage_p.java b/htroot/ConfigSearchPage_p.javaindex 429153a7f..c2ccb1990 100644--- a/htroot/ConfigSearchPage_p.java+++ b/htroot/ConfigSearchPage_p.java@@ -100,7 +100,7 @@ public class ConfigSearchPage_p {// if (post.getBoolean("search.navigation.filetype")) nav += "filetype,";if (post.getBoolean("search.navigation.protocol")) nav += "protocol,";// if (post.getBoolean("search.navigation.hosts")) nav += "hosts,";- if (post.getBoolean("search.navigation.language")) nav += "language,";+ // if (post.getBoolean("search.navigation.language")) nav += "language,";// if (post.getBoolean("search.navigation.authors")) nav += "authors,";// if (post.getBoolean("search.navigation.collections")) nav += "collections,";// if (post.getBoolean("search.navigation.namespace")) nav += "namespace,";@@ -248,7 +248,7 @@ public class ConfigSearchPage_p {// prop.put("search.navigation.filetype", sb.getConfig("search.navigation", "").indexOf("filetype",0) >= 0 ? 1 : 0);prop.put("search.navigation.protocol", sb.getConfig("search.navigation", "").indexOf("protocol",0) >= 0 ? 1 : 0);// prop.put("search.navigation.hosts", sb.getConfig("search.navigation", "").indexOf("hosts",0) >= 0 ? 1 : 0);- prop.put("search.navigation.language", sb.getConfig("search.navigation", "").indexOf("language",0) >= 0 ? 1 : 0);+ // prop.put("search.navigation.language", sb.getConfig("search.navigation", "").indexOf("language",0) >= 0 ? 1 : 0);// prop.put("search.navigation.authors", sb.getConfig("search.navigation", "").indexOf("authors",0) >= 0 ? 1 : 0);// prop.put("search.navigation.collections", sb.getConfig("search.navigation", "").indexOf("collections",0) >= 0 ? 1 : 0);// prop.put("search.navigation.namespace", sb.getConfig("search.navigation", "").indexOf("namespace",0) >= 0 ? 1 : 0);diff --git a/htroot/yacysearchtrailer.java b/htroot/yacysearchtrailer.javaindex 8edde837f..dc4106980 100644--- a/htroot/yacysearchtrailer.java+++ b/htroot/yacysearchtrailer.java@@ -128,50 +128,6 @@ public class yacysearchtrailer {int count;Iterator<String> navigatorIterator;- // language navigators- final ScoreMap<String> languageNavigator = theSearch.languageNavigator;- if (languageNavigator == null || languageNavigator.isEmpty()) {- prop.put("nav-languages", 0);- } else {- prop.put("nav-languages", 1);- navigatorIterator = languageNavigator.keys(false);- int i = 0, pos = 0, neg = 0;- String nav, rawNav;- while (i < theSearch.getQuery().getStandardFacetsMaxCount() && navigatorIterator.hasNext()) {- name = navigatorIterator.next();- count = languageNavigator.get(name);- if (count == 0) break;- nav = "%2Flanguage%2F" + name;- /* Avoid double percent encoding in QueryParams.navurl */- rawNav = "/language/" + name;- final String navUrl;- if (theSearch.query.modifier.language == null || !theSearch.query.modifier.language.contains(name)) {- pos++;- prop.put("nav-languages_element_" + i + "_on", 1);- prop.put(fileType, "nav-languages_element_" + i + "_modifier", nav);- navUrl = QueryParams.navurl(fileType, 0, theSearch.query, rawNav, false, authenticated).toString();- } else {- neg++;- prop.put("nav-languages_element_" + i + "_on", 0);- prop.put(fileType, "nav-languages_element_" + i + "_modifier", "-" + nav);- navUrl = QueryParams.navUrlWithSingleModifierRemoved(fileType, 0, theSearch.query, rawNav,- authenticated);- }- String longname = ISO639.country(name);- prop.put(fileType, "nav-languages_element_" + i + "_name", longname == null ? name : longname);- prop.put(fileType, "nav-languages_element_" + i + "_url", navUrl);- prop.put(fileType, "nav-languages_element_" + i + "_id", "languages_" + i);- prop.put("nav-languages_element_" + i + "_count", count);- prop.put("nav-languages_element_" + i + "_nl", 1);- i++;- }- prop.put("nav-languages_element", i);- prop.put("nav-languages_count", i);- i--;- prop.put("nav-languages_element_" + i + "_nl", 0);- if (pos == 1 && neg == 0) prop.put("nav-languages", 0); // this navigation is not useful- }-// topics navigatorfinal ScoreMap<String> topicNavigator = theSearch.getTopicNavigator(TOPWORDS_MAXCOUNT);if (topicNavigator == null || topicNavigator.isEmpty()) {diff --git a/source/net/yacy/search/navigator/LanguageNavigator.java b/source/net/yacy/search/navigator/LanguageNavigator.javaindex ffebc93eb..6e238c176 100644--- a/source/net/yacy/search/navigator/LanguageNavigator.java+++ b/source/net/yacy/search/navigator/LanguageNavigator.java@@ -22,7 +22,9 @@*/package net.yacy.search.navigator;+import java.util.Collection;import net.yacy.cora.sorting.ScoreMap;+import net.yacy.kelondro.data.meta.URIMetadataNode;import net.yacy.kelondro.util.ISO639;import net.yacy.search.query.QueryModifier;import net.yacy.search.schema.CollectionSchema;@@ -77,6 +79,40 @@ public class LanguageNavigator extends StringNavigator implements Navigator {}}+ /**+ * Increase the score for the key value contained in the defined field in+ * the doc, if no language info in doc try to use associated word reference.+ * @param doc URIMetadataNode with field for the key content+ */+ @Override+ public void incDoc(URIMetadataNode doc) {+ if (field != null) {+ Object val = doc.getFieldValue(field.getSolrFieldName());+ if (val != null) {+ if (val instanceof Collection) {+ Collection<?> ll = (Collection<?>) val;+ for (Object obj : ll) {+ if (obj instanceof String) {+ final String s = (String) obj;+ if (!s.isEmpty()) {+ this.inc(s);+ }+ }+ }+ } else {+ this.inc((String) val);+ }+ } else {+ if (doc.word() != null && doc.word().getLanguageString() != null) {+ /* Increase the language navigator here only if the word reference+ * did not include information about language. Otherwise it should be done earlier in addRWIs() */+ final String lang = doc.word().getLanguageString();+ this.inc(lang);+ }+ }+ }+ }+@Overridepublic String getQueryModifier(final String key) {return "/language/" + key;diff --git a/source/net/yacy/search/navigator/NavigatorPlugins.java b/source/net/yacy/search/navigator/NavigatorPlugins.javaindex ae55236c5..ca5b1aeec 100644--- a/source/net/yacy/search/navigator/NavigatorPlugins.java+++ b/source/net/yacy/search/navigator/NavigatorPlugins.java@@ -42,7 +42,7 @@ public class NavigatorPlugins {Map<String, String> defaultnavplugins = new TreeMap<String, String>();defaultnavplugins.put("filetype", "Filetype");defaultnavplugins.put("hosts", "Provider");- // defaultnavplugins.put("language", "Language");+ defaultnavplugins.put("language", "Language");defaultnavplugins.put("authors", "Authors");defaultnavplugins.put("collections", "Collection");defaultnavplugins.put("namespace", "Wiki Name Space");@@ -91,11 +91,11 @@ public class NavigatorPlugins {if (navname.contains("hosts")) {navigatorPlugins.put("hosts", new HostNavigator("Provider", CollectionSchema.host_s));}-/*+if (navname.contains("language")) {navigatorPlugins.put("language", new LanguageNavigator("Language"));}-*/+if (navname.contains("namespace")) {navigatorPlugins.put("namespace", new NameSpaceNavigator("Wiki Name Space"));}diff --git a/source/net/yacy/search/query/SearchEvent.java b/source/net/yacy/search/query/SearchEvent.javaindex a46b5b290..cb4dff93c 100644--- a/source/net/yacy/search/query/SearchEvent.java+++ b/source/net/yacy/search/query/SearchEvent.java@@ -168,9 +168,6 @@ public final class SearchEvent implements ScoreMapUpdatesListener {/** a counter for file types */public final ConcurrentScoreMap<String> dateNavigator;- /** a counter for appearance of languages */- public final ScoreMap<String> languageNavigator;-/** counters for Vocabularies; key is metatag.getVocabularyName() */public final Map<String, ScoreMap<String>> vocabularyNavigator;@@ -360,7 +357,6 @@ public final class SearchEvent implements ScoreMapUpdatesListener {this.protocolNavigator = navcfg.contains("protocol") ? new ConcurrentScoreMap<String>(this) : null;this.dateNavigator = navcfg.contains("date") ? new ConcurrentScoreMap<String>(this) : null;this.topicNavigatorCount = navcfg.contains("topics") ? MAX_TOPWORDS : 0;- this.languageNavigator = navcfg.contains("language") ? new ConcurrentScoreMap<String>(this) : null;this.vocabularyNavigator = new TreeMap<String, ScoreMap<String>>();// prepare configured search navigation (plugins)this.navigatorPlugins = NavigatorPlugins.initFromCfgString(navcfg);@@ -799,14 +795,6 @@ public final class SearchEvent implements ScoreMapUpdatesListener {// increase counter for statisticsif (local) this.local_rwi_available.incrementAndGet(); else this.remote_rwi_available.incrementAndGet();- /* Fisrt filtering pass is now complete : update navigator counters that can already be updated */- if(this.languageNavigator != null) {- final String lang = iEntry.getLanguageString();- if(ISO639.exists(lang)) {- this.languageNavigator.inc(lang);- }- }-successcounter++;}if (System.currentTimeMillis() >= timeout) ConcurrentLog.warn("SearchEvent", "rwi normalization ended with timeout = " + maxtime);@@ -1147,21 +1135,6 @@ public final class SearchEvent implements ScoreMapUpdatesListener {if (fcts != null) this.dateNavigator.inc(fcts);}- if (this.languageNavigator != null) {- fcts = facets.get(CollectionSchema.language_s.getSolrFieldName());- if (fcts != null) {- // remove unknown languages- Iterator<String> i = fcts.iterator();- while (i.hasNext()) {- String lang = i.next();- if (!ISO639.exists(lang)) {- i.remove();- }- }- this.languageNavigator.inc(fcts);- }- }-if (this.protocolNavigator != null) {fcts = facets.get(CollectionSchema.url_protocol_s.getSolrFieldName());if (fcts != null) {@@ -1227,17 +1200,6 @@ public final class SearchEvent implements ScoreMapUpdatesListener {}}- if (this.languageNavigator != null) {- if (facets == null || !facets.containsKey(CollectionSchema.language_s.getSolrFieldName())) {- final String lang = doc.language();- if (ISO639.exists(lang)) {- this.languageNavigator.inc(lang);- }-- }- }--if (this.protocolNavigator != null) {if (facets == null || !facets.containsKey(CollectionSchema.url_protocol_s.getSolrFieldName())) {final String protocol = doc.url().getProtocol();@@ -1595,17 +1557,6 @@ public final class SearchEvent implements ScoreMapUpdatesListener {}}- if(this.languageNavigator != null) {- if(page.word() == null || page.word().getLanguageString() == null) {- /* Increase the language navigator here only if the word reference- * did not include information about language. Otherwise it should be done earlier in addRWIs() */- final String lang = page.language();- if(ISO639.exists(lang)) {- this.languageNavigator.inc(lang);- }- }- }-if(this.protocolNavigator != null && page.url() != null) {final String protocol = page.url().getProtocol();if(protocol != null) {@@ -1646,14 +1597,6 @@ public final class SearchEvent implements ScoreMapUpdatesListener {this.remote_rwi_available.decrementAndGet();}}-- /* The language navigator may have been incremented in the addRWIs() function */- if (this.languageNavigator != null) {- String lang = entry.getLanguageString();- if (lang != null && this.languageNavigator.get(lang) > 0) {- this.languageNavigator.dec(lang);- }- }}/**@@ -1745,22 +1688,6 @@ public final class SearchEvent implements ScoreMapUpdatesListener {}}- if (this.languageNavigator != null) {- if (navIncrementedWithFacets) {- fcts = facets.get(CollectionSchema.language_s.getSolrFieldName());- } else {- fcts = null;- }- String lang = entry.language();- if (lang != null) {- if (navIncrementedEarlier || (fcts != null && fcts.containsKey(lang))) {- if (this.languageNavigator.get(lang) > 0) {- this.languageNavigator.dec(lang);- }- }- }- }-if (this.protocolNavigator != null) {if (navIncrementedWithFacets) {fcts = facets.get(CollectionSchema.url_protocol_s.getSolrFieldName());