Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
added hints to ranking to make ranking boosts using vocabularies easier
Michael Peter Christenee9ec4004887
diff --git a/htroot/RankingSolr_p.html b/htroot/RankingSolr_p.htmlindex d5ec31698..75427b761 100644--- a/htroot/RankingSolr_p.html+++ b/htroot/RankingSolr_p.html@@ -36,7 +36,8 @@<input type="submit" name="EnterBF" value="Set Boost Function" /><input type="submit" name="ResetBF" value="Re-Set to default" /></dd>- </dl>+ </dl><br/>+ #(boosthint)#::You can boost with vocabularies, use the occurrence counters #[vocabulariesvoccount]# and #[vocabulariesvoclogcount]#.#(/boosthint)#</fieldset></form><form class="dsearch" action="RankingSolr_p.html" method="post" enctype="multipart/form-data">@@ -56,7 +57,24 @@<input type="submit" name="EnterBQ" value="Set Boost Query" /><input type="submit" name="ResetBQ" value="Re-Set to default" /></dd>- </dl>+ </dl><br/>+ #(boosthint)#::+ You can boost with vocabularies, use the field '#[vocabulariesfield]#' with values #[vocabulariesavailable]#. You can also boost on logarithmic occurrence counters of the fields #[vocabulariesvoclogcounts]#.<br/>+ #{facets}#+ <table class="sortable" border="0" style="float:left">+ <tr class="TableCellDark">+ <td align="left" colspan="5" nowrap class="pending">#[facetname]#</td>+ <td align="right" colspan="5" nowrap class="listingok">#</td>+ </tr>+ #{facet}#+ <tr class="TableCellLight">+ <td align="left" colspan="5" nowrap class="pending">#[key]#</td>+ <td align="right" colspan="5" nowrap class="listingok">#[count]#</td>+ </tr>+ #{/facet}#+ </table> + #{/facets}#+ #(/boosthint)#</fieldset></form><form class="dsearch" action="RankingSolr_p.html" method="post" enctype="multipart/form-data">diff --git a/htroot/RankingSolr_p.java b/htroot/RankingSolr_p.javaindex 627865534..f543fb75a 100644--- a/htroot/RankingSolr_p.java+++ b/htroot/RankingSolr_p.java@@ -18,11 +18,20 @@* If not, see <http://www.gnu.org/licenses/>.*/+import java.io.IOException;+import java.util.ArrayList;+import java.util.Collection;+import java.util.HashMap;+import java.util.LinkedHashMap;import java.util.Map;+import java.util.TreeMap;+import java.util.Map.Entry;import net.yacy.cora.federate.solr.Ranking;import net.yacy.cora.federate.solr.SchemaDeclaration;import net.yacy.cora.protocol.RequestHeader;+import net.yacy.cora.sorting.ReversibleScoreMap;+import net.yacy.cora.util.ConcurrentLog;import net.yacy.search.Switchboard;import net.yacy.search.SwitchboardConstants;import net.yacy.search.query.SearchEventCache;@@ -30,6 +39,7 @@ import net.yacy.search.schema.CollectionConfiguration;import net.yacy.search.schema.CollectionSchema;import net.yacy.server.serverObjects;import net.yacy.server.serverSwitch;+import org.apache.solr.common.params.CommonParams;import org.apache.solr.common.params.DisMaxParams;@@ -159,6 +169,60 @@ public class RankingSolr_p {prop.put("profiles", 4);prop.put("profileNr", profileNr);+ // make boost hints for vocabularies+ Map<String, ReversibleScoreMap<String>> vocabularyFacet;+ try {+ vocabularyFacet = sb.index.fulltext().getDefaultConnector().getFacets(CollectionSchema.vocabularies_sxt.getSolrFieldName() + ":[* TO *]", 100, CollectionSchema.vocabularies_sxt.getSolrFieldName());+ } catch (IOException e) {+ ConcurrentLog.logException(e);+ vocabularyFacet = new HashMap<>();+ }+ if (vocabularyFacet.size() == 0) {+ prop.put("boosthint", 0);+ } else {+ prop.put("boosthint", 1);+ prop.putHTML("boosthint_vocabulariesfield", CollectionSchema.vocabularies_sxt.getSolrFieldName());+ ReversibleScoreMap<String> vokcounts = vocabularyFacet.values().iterator().next();+ Collection<String> vocnames = vokcounts.keyList(true);+ prop.putHTML("boosthint_vocabulariesavailable", vocnames.toString());+ ArrayList<String> voccountFields = new ArrayList<>();+ ArrayList<String> voclogcountFields = new ArrayList<>();+ ArrayList<String> voclogcountsFields = new ArrayList<>();+ ArrayList<String> ff = new ArrayList<>();+ for (String vocname: vocnames) {+ voccountFields.add(CollectionSchema.VOCABULARY_PREFIX + vocname + CollectionSchema.VOCABULARY_COUNT_SUFFIX);+ voclogcountFields.add(CollectionSchema.VOCABULARY_PREFIX + vocname + CollectionSchema.VOCABULARY_LOGCOUNT_SUFFIX);+ voclogcountsFields.add(CollectionSchema.VOCABULARY_PREFIX + vocname + CollectionSchema.VOCABULARY_LOGCOUNTS_SUFFIX);+ }+ ff.addAll(voclogcountFields);+ ff.addAll(voclogcountsFields);+ prop.putHTML("boosthint_vocabulariesvoccount", voccountFields.toString());+ prop.putHTML("boosthint_vocabulariesvoclogcount", voclogcountFields.toString());+ prop.putHTML("boosthint_vocabulariesvoclogcounts", voclogcountsFields.toString());+ String[] facetfields = ff.toArray(new String[ff.size()]);+ int fc = 0;+ try {+ LinkedHashMap<String, ReversibleScoreMap<String>> facets = sb.index.fulltext().getDefaultConnector().getFacets("*:*", 100, facetfields);+ facets.put(CollectionSchema.vocabularies_sxt.getSolrFieldName(), vokcounts);+ for (Map.Entry<String, ReversibleScoreMap<String>> facetentry: facets.entrySet()) {+ ReversibleScoreMap<String> facetfieldmap = facetentry.getValue();+ if (facetfieldmap.size() == 0) continue;+ TreeMap<String, Integer> statMap = new TreeMap<>();+ for (String k: facetfieldmap) statMap.put(k, facetfieldmap.get(k));+ prop.put("boosthint_facets_" + fc + "_facetname", facetentry.getKey());+ int c = 0; for (Entry<String, Integer> entry: statMap.entrySet()) {+ prop.put("boosthint_facets_" + fc + "_facet_" + c + "_key", entry.getKey());+ prop.put("boosthint_facets_" + fc + "_facet_" + c + "_count", entry.getValue());+ c++;+ }+ prop.put("boosthint_facets_" + fc + "_facet", c);+ fc++;+ }+ } catch (IOException e) {+ }+ prop.put("boosthint_facets", fc);+ }+return prop;}