Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
added in RankingSolr_p.html a select box to switch between different ranking situations. By default, four situations can be configured.
Michael Peter Christen2db058b5518d
diff --git a/htroot/RankingSolr_p.html b/htroot/RankingSolr_p.htmlindex c930c6ed3..9a88dcc2d 100644--- a/htroot/RankingSolr_p.html+++ b/htroot/RankingSolr_p.html@@ -10,8 +10,17 @@<h2>Solr Ranking Configuration</h2><p>These are ranking attributes for Solr. This ranking applies for internal and remote (P2P or shard) Solr access.</p>+ <form action="RankingSolr_p.html" method="get" enctype="multipart/form-data" accept-charset="UTF-8">+ Select a profile:+ <select id="profile" name="profileNr" onchange='submit()'>+ #{profiles}#+ <option value="#[nr]#" #(selected)#::selected="selected"#(/selected)#>#[name]#</option>+ #{/profiles}#+ </select>+ </form><form class="dsearch" action="RankingSolr_p.html" method="post" enctype="multipart/form-data"><fieldset>+ <input type="hidden" name="profileNr" value="#[profileNr]#" /><legend>Boost Function</legend>A Boost Function can combine numeric values from the result document to produce a number which is either added or multiplied with the other boost value from the query result.To see all available fields, see the <a href="IndexSchema_p.html">YaCy Solr Schema</a> and look for numeric values (these are names with suffix '_i').diff --git a/htroot/RankingSolr_p.java b/htroot/RankingSolr_p.javaindex 2184efe5d..69917a348 100644--- a/htroot/RankingSolr_p.java+++ b/htroot/RankingSolr_p.java@@ -39,6 +39,9 @@ public class RankingSolr_p {// clean up all search eventsSearchEventCache.cleanupEvents(true);sb.index.clearCache(); // every time the ranking is changed we need to remove old orderings++ int profileNr = 0;+ if (post != null) profileNr = post.getInt("profileNr", profileNr);if (post != null && post.containsKey("EnterBoosts")) {StringBuilder boostString = new StringBuilder(); // SwitchboardConstants.SEARCH_RANKING_SOLR_BOOST;@@ -60,28 +63,28 @@ public class RankingSolr_p {}if (boostString.length() > 0) {String s = boostString.toString();- sb.setConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTFIELDS_ + "0", s);- sb.index.fulltext().getDefaultConfiguration().getRanking(0).updateBoosts(s);+ sb.setConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTFIELDS_ + profileNr, s);+ sb.index.fulltext().getDefaultConfiguration().getRanking(profileNr).updateBoosts(s);}}if (post != null && post.containsKey("ResetBoosts")) {String s = "text_t^2.0,url_paths_sxt^20.0,title^100.0,synonyms_sxt^1.0";- sb.setConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTFIELDS_ + "0", s);- sb.index.fulltext().getDefaultConfiguration().getRanking(0).updateBoosts(s);+ sb.setConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTFIELDS_ + profileNr, s);+ sb.index.fulltext().getDefaultConfiguration().getRanking(profileNr).updateBoosts(s);}if (post != null && post.containsKey("EnterBQ")) {String bq = post.get("bq");if (bq != null) {- sb.setConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTQUERY_ + "0", bq);- sb.index.fulltext().getDefaultConfiguration().getRanking(0).setBoostQuery(bq);+ sb.setConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTQUERY_ + profileNr, bq);+ sb.index.fulltext().getDefaultConfiguration().getRanking(profileNr).setBoostQuery(bq);}}if (post != null && post.containsKey("ResetBQ")) {String bq = "fuzzy_signature_unique_b:true^100000.0";if (bq != null) {- sb.setConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTQUERY_ + "0", bq);- sb.index.fulltext().getDefaultConfiguration().getRanking(0).setBoostQuery(bq);+ sb.setConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTQUERY_ + profileNr, bq);+ sb.index.fulltext().getDefaultConfiguration().getRanking(profileNr).setBoostQuery(bq);}}@@ -89,27 +92,27 @@ public class RankingSolr_p {String bf = post.get("bf");String mode = post.get("mode");if (bf != null) {- sb.setConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTFUNCTION_ + "0", bf);- sb.setConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTFUNCTIONMODE_ + "0", mode);- sb.index.fulltext().getDefaultConfiguration().getRanking(0).setBoostFunction(bf);- sb.index.fulltext().getDefaultConfiguration().getRanking(0).setMode(Ranking.BoostFunctionMode.valueOf(mode));+ sb.setConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTFUNCTION_ + profileNr, bf);+ sb.setConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTFUNCTIONMODE_ + profileNr, mode);+ sb.index.fulltext().getDefaultConfiguration().getRanking(profileNr).setBoostFunction(bf);+ sb.index.fulltext().getDefaultConfiguration().getRanking(profileNr).setMode(Ranking.BoostFunctionMode.valueOf(mode));}}if (post != null && post.containsKey("ResetBF")) {String bf = ""; //"div(add(1,references_i),pow(add(1,inboundlinkscount_i),1.6))";String mode = "add";if (bf != null) {- sb.setConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTFUNCTION_ + "0", bf);- sb.setConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTFUNCTIONMODE_ + "0", mode);- sb.index.fulltext().getDefaultConfiguration().getRanking(0).setBoostFunction(bf);- sb.index.fulltext().getDefaultConfiguration().getRanking(0).setMode(Ranking.BoostFunctionMode.valueOf(mode));+ sb.setConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTFUNCTION_ + profileNr, bf);+ sb.setConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTFUNCTIONMODE_ + profileNr, mode);+ sb.index.fulltext().getDefaultConfiguration().getRanking(profileNr).setBoostFunction(bf);+ sb.index.fulltext().getDefaultConfiguration().getRanking(profileNr).setMode(Ranking.BoostFunctionMode.valueOf(mode));}}final serverObjects prop = new serverObjects();int i = 0;- Ranking ranking = sb.index.fulltext().getDefaultConfiguration().getRanking(0);+ Ranking ranking = sb.index.fulltext().getDefaultConfiguration().getRanking(profileNr);for (SchemaDeclaration field: CollectionSchema.values()) {if (!field.isSearchable()) continue;prop.put("boosts_" + i + "_field", field.getSolrFieldName());@@ -130,6 +133,14 @@ public class RankingSolr_p {prop.put("add.checked", ranking.getMethod() == Ranking.BoostFunctionMode.add ? 1 : 0);prop.put("multiply.checked", ranking.getMethod() == Ranking.BoostFunctionMode.add ? 0 : 1);+ for (int j = 0; j < 4; j++) {+ prop.put("profiles_" + j + "_nr", j);+ prop.put("profiles_" + j + "_name", sb.getConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTNAME_ + j, "N.N."));+ prop.put("profiles_" + j + "_selected", profileNr == j ? 1 : 0);+ }+ prop.put("profiles", 4);+ prop.put("profileNr", profileNr);+return prop;}