diff --git a/defaults/yacy.init b/defaults/yacy.init index 552414b0e..5e9b02eec 100644 --- a/defaults/yacy.init +++ b/defaults/yacy.init @@ -960,22 +960,18 @@ search.ranking.solr.collection.boostname.tmp.0=_default search.ranking.solr.collection.boostfields.tmp.0=text_t^2.0,url_paths_sxt^50.0,title^100.0,synonyms_sxt^1.0 search.ranking.solr.collection.boostquery.tmp.0=fuzzy_signature_unique_b:true^100000.0 search.ranking.solr.collection.boostfunction.tmp.0= -search.ranking.solr.collection.boostfunctionmode.tmp.0=add search.ranking.solr.collection.boostname.tmp.1=_date search.ranking.solr.collection.boostfields.tmp=text_t^1.0 search.ranking.solr.collection.boostquery.tmp.1=fuzzy_signature_unique_b:true^100000.0 search.ranking.solr.collection.boostfunction.tmp.1=recip(ms(NOW,last_modified),3.16e-11,1,1) -search.ranking.solr.collection.boostfunctionmode.tmp.1=multiply search.ranking.solr.collection.boostname.tmp.2=_intranet search.ranking.solr.collection.boostfields.tmp.2=text_t^2.0,url_paths_sxt^20.0,title^10000.0,h1_txt^10000.0,h2_txt^1000.0,synonyms_sxt^1.0 search.ranking.solr.collection.boostquery.tmp.2=fuzzy_signature_unique_b:true^100000.0 search.ranking.solr.collection.boostfunction.tmp.2=pow(url_chars_i,2) -search.ranking.solr.collection.boostfunctionmode.tmp.2=add search.ranking.solr.collection.boostname.tmp.3=_unused3 search.ranking.solr.collection.boostfields.tmp.3=text_t^1.0 search.ranking.solr.collection.boostquery.tmp.3=fuzzy_signature_unique_b:true^100000.0 search.ranking.solr.collection.boostfunction.tmp.3=div(add(1,references_i),add(url_chars_i,pow(clickdepth_i,3))) -search.ranking.solr.collection.boostfunctionmode.tmp.3=multiply # the following values are used to identify duplicate content search.ranking.solr.doubledetection.minlength=3 diff --git a/htroot/RankingSolr_p.html b/htroot/RankingSolr_p.html index a1639ba7f..d19398a00 100644 --- a/htroot/RankingSolr_p.html +++ b/htroot/RankingSolr_p.html @@ -22,20 +22,15 @@
Boost Function - 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. + A Boost Function can combine numeric values from the result document to produce a number which is multiplied with the score value from the query result. To see all available fields, see the YaCy Solr Schema and look for numeric values (these are names with suffix '_i'). To find out which kind of operations are possible, see the Solr Function Query documentation. - Example: to order by date, use "recip(ms(NOW,last_modified),3.16e-11,1,1)", to order by clickdepth, use "div(100,add(clickdepth_i,1))". + Example: to order by date, use "recip(rord(last_modified),1,1000,1000)", to order by clickdepth, use "div(100,add(clickdepth_i,1))".
-
+
-
-
- add    - multiply -
diff --git a/htroot/RankingSolr_p.java b/htroot/RankingSolr_p.java index 69917a348..a25b6e930 100644 --- a/htroot/RankingSolr_p.java +++ b/htroot/RankingSolr_p.java @@ -90,22 +90,16 @@ public class RankingSolr_p { if (post != null && post.containsKey("EnterBF")) { String bf = post.get("bf"); - String mode = post.get("mode"); if (bf != null) { 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_ + 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)); } } @@ -129,9 +123,6 @@ public class RankingSolr_p { prop.put("boosts", i); prop.put("bq", ranking.getBoostQuery()); prop.put("bf", ranking.getBoostFunction()); - prop.put("modeKey", ranking.getMethod() == Ranking.BoostFunctionMode.add ? "bf" : "boost"); - 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); diff --git a/htroot/gsa/searchresult.java b/htroot/gsa/searchresult.java index d10817237..847ae56df 100644 --- a/htroot/gsa/searchresult.java +++ b/htroot/gsa/searchresult.java @@ -109,7 +109,7 @@ public class searchresult { // get a solr query string QueryGoal qg = new QueryGoal(originalQuery, originalQuery); - StringBuilder solrQ = qg.collectionQueryString(sb.index.fulltext().getDefaultConfiguration()); + StringBuilder solrQ = qg.collectionQueryString(sb.index.fulltext().getDefaultConfiguration(), 0); post.put("defType", "edismax"); post.put(CommonParams.Q, solrQ.toString()); post.put(CommonParams.ROWS, post.remove("num")); @@ -130,8 +130,8 @@ public class searchresult { Ranking ranking = sb.index.fulltext().getDefaultConfiguration().getRanking(0); String bq = ranking.getBoostQuery(); String bf = ranking.getBoostFunction(); - if (bq.length() > 0) post.put("bq", bq); // a boost query that moves double content to the back - if (bf.length() > 0) post.put(ranking.getMethod() == Ranking.BoostFunctionMode.add ? "bf" : "boost", bf); // a boost function extension, see http://wiki.apache.org/solr/ExtendedDisMax#bf_.28Boost_Function.2C_additive.29 + if (bq.length() > 0) post.put("bq", bq); + if (bf.length() > 0) post.put("boost", bf); // a boost function extension, see http://wiki.apache.org/solr/ExtendedDisMax#bf_.28Boost_Function.2C_additive.29 } post.put(CommonParams.FL, CollectionSchema.content_type.getSolrFieldName() + ',' + diff --git a/htroot/solr/select.java b/htroot/solr/select.java index 1c85531e9..5ac40274d 100644 --- a/htroot/solr/select.java +++ b/htroot/solr/select.java @@ -146,6 +146,9 @@ public class select { if (post == null) return null; sb.intermissionAllThreads(3000); // tell all threads to do nothing for a specific time + // get the ranking profile id + int profileNr = post.getInt("profileNr", 0); + // rename post fields according to result style if (!post.containsKey(CommonParams.Q) && post.containsKey("query")) { String querystring = post.get("query", ""); @@ -154,7 +157,7 @@ public class select { querystring = modifier.parse(querystring); modifier.apply(post); QueryGoal qg = new QueryGoal(querystring, querystring); - StringBuilder solrQ = qg.collectionQueryString(sb.index.fulltext().getDefaultConfiguration()); + StringBuilder solrQ = qg.collectionQueryString(sb.index.fulltext().getDefaultConfiguration(), profileNr); post.put(CommonParams.Q, solrQ.toString()); // sru patch } String q = post.get(CommonParams.Q, ""); @@ -162,14 +165,14 @@ public class select { if (!post.containsKey(CommonParams.ROWS)) post.put(CommonParams.ROWS, post.remove("maximumRecords", 10)); // sru patch post.put(CommonParams.ROWS, Math.min(post.getInt(CommonParams.ROWS, 10), (authenticated) ? 10000 : 100)); - // set default ranking if this is not given in the request - if (!post.containsKey("sort")) { + // set ranking according to profile number if ranking attributes are not given in the request + if (!post.containsKey("sort") && !post.containsKey("bq") && !post.containsKey("bf") && !post.containsKey("boost")) { if (!post.containsKey("defType")) post.put("defType", "edismax"); - Ranking ranking = sb.index.fulltext().getDefaultConfiguration().getRanking(0); + Ranking ranking = sb.index.fulltext().getDefaultConfiguration().getRanking(profileNr); String bq = ranking.getBoostQuery(); String bf = ranking.getBoostFunction(); - if (!post.containsKey("bq") && bq.length() > 0) post.put("bq", bq); // a boost query that moves double content to the back - if (!(post.containsKey("bf") || post.containsKey("boost")) && bf.length() > 0) post.put(ranking.getMethod() == Ranking.BoostFunctionMode.add ? "bf" : "boost", bf); // a boost function extension, see http://wiki.apache.org/solr/ExtendedDisMax#bf_.28Boost_Function.2C_additive.29 + if (bq.length() > 0) post.put("bq", bq); + if (bf.length() > 0) post.put("boost", bf); // a boost function extension, see http://wiki.apache.org/solr/ExtendedDisMax#bf_.28Boost_Function.2C_additive.29 } // get a response writer for the result diff --git a/source/net/yacy/cora/federate/solr/Ranking.java b/source/net/yacy/cora/federate/solr/Ranking.java index a7a0ebeb3..dc20138e3 100644 --- a/source/net/yacy/cora/federate/solr/Ranking.java +++ b/source/net/yacy/cora/federate/solr/Ranking.java @@ -36,13 +36,8 @@ public class Ranking { private static float quantRate = 0.5f; // to be filled with search.ranking.solr.doubledetection.quantrate private static int minTokenLen = 3; // to be filled with search.ranking.solr.doubledetection.minlength - public static enum BoostFunctionMode { - add, multiply; - } - private Map fieldBoosts; private String name, boostQuery, boostFunction; - private BoostFunctionMode mode; public Ranking() { super(); @@ -50,7 +45,6 @@ public class Ranking { this.fieldBoosts = new LinkedHashMap(); this.boostQuery = ""; this.boostFunction = ""; - this.mode = BoostFunctionMode.add; } @@ -117,15 +111,6 @@ public class Ranking { public String getBoostFunction() { return this.boostFunction; } - - public void setMode(BoostFunctionMode method) { - this.mode = method; - } - - public BoostFunctionMode getMethod() { - return this.mode; - } - /* * duplicate check static methods diff --git a/source/net/yacy/search/Switchboard.java b/source/net/yacy/search/Switchboard.java index 5bf873240..3affb3e82 100644 --- a/source/net/yacy/search/Switchboard.java +++ b/source/net/yacy/search/Switchboard.java @@ -470,7 +470,6 @@ public final class Switchboard extends serverSwitch { r.updateBoosts(this.getConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTFIELDS_ + i, "text_t^1.0")); r.setBoostQuery(this.getConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTQUERY_ + i, "")); r.setBoostFunction(this.getConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTFUNCTION_ + i, "")); - r.setMode(Ranking.BoostFunctionMode.valueOf(this.getConfig(SwitchboardConstants.SEARCH_RANKING_SOLR_COLLECTION_BOOSTFUNCTIONMODE_ + i, "add"))); } // initialize index diff --git a/source/net/yacy/search/SwitchboardConstants.java b/source/net/yacy/search/SwitchboardConstants.java index 46f4667c2..b62014156 100644 --- a/source/net/yacy/search/SwitchboardConstants.java +++ b/source/net/yacy/search/SwitchboardConstants.java @@ -494,7 +494,6 @@ public final class SwitchboardConstants { public static final String SEARCH_RANKING_SOLR_COLLECTION_BOOSTFIELDS_ = "search.ranking.solr.collection.boostfields.tmp."; public static final String SEARCH_RANKING_SOLR_COLLECTION_BOOSTQUERY_ = "search.ranking.solr.collection.boostquery.tmp."; public static final String SEARCH_RANKING_SOLR_COLLECTION_BOOSTFUNCTION_ = "search.ranking.solr.collection.boostfunction.tmp."; - public static final String SEARCH_RANKING_SOLR_COLLECTION_BOOSTFUNCTIONMODE_ = "search.ranking.solr.collection.boostfunctionmode.tmp."; /** * system tray diff --git a/source/net/yacy/search/query/QueryGoal.java b/source/net/yacy/search/query/QueryGoal.java index 2b7819d83..f12e247f6 100644 --- a/source/net/yacy/search/query/QueryGoal.java +++ b/source/net/yacy/search/query/QueryGoal.java @@ -195,7 +195,7 @@ public class QueryGoal { for (final byte[] b: blues) this.include_hashes.remove(b); } - public StringBuilder collectionQueryString(CollectionConfiguration configuration) { + public StringBuilder collectionQueryString(CollectionConfiguration configuration, int rankingProfile) { final StringBuilder q = new StringBuilder(80); // parse special requests @@ -222,7 +222,7 @@ public class QueryGoal { // combine these queries for all relevant fields wc = 0; Float boost; - Ranking r = configuration.getRanking(0); + Ranking r = configuration.getRanking(rankingProfile); for (Map.Entry entry: r.getBoostMap()) { SchemaDeclaration field = entry.getKey(); boost = entry.getValue(); diff --git a/source/net/yacy/search/query/QueryParams.java b/source/net/yacy/search/query/QueryParams.java index ecd3e66e4..87a5bbfe4 100644 --- a/source/net/yacy/search/query/QueryParams.java +++ b/source/net/yacy/search/query/QueryParams.java @@ -384,14 +384,15 @@ public final class QueryParams { if (this.queryGoal.getIncludeStrings().size() == 0) return null; // construct query final SolrQuery params = new SolrQuery(); - params.setQuery(this.queryGoal.collectionQueryString(this.indexSegment.fulltext().getDefaultConfiguration()).toString()); + int rankingProfile = this.ranking.coeff_date == RankingProfile.COEFF_MAX ? 1 : (this.modifier.sitehash != null || this.modifier.sitehost != null) ? 2 : 0; + params.setQuery(this.queryGoal.collectionQueryString(this.indexSegment.fulltext().getDefaultConfiguration(), rankingProfile).toString()); params.setParam("defType", "edismax"); - Ranking ranking = indexSegment.fulltext().getDefaultConfiguration().getRanking(0); - //Ranking ranking = indexSegment.fulltext().getDefaultConfiguration().getRanking(this.ranking.coeff_date == RankingProfile.COEFF_MAX ? 1 : (this.modifier.sitehash != null || this.modifier.sitehost != null) ? 2 : 0); // for a by-date ranking select different ranking profile + Ranking ranking = indexSegment.fulltext().getDefaultConfiguration().getRanking(rankingProfile); // for a by-date ranking select different ranking profile + String bq = ranking.getBoostQuery(); String bf = ranking.getBoostFunction(); - if (bq.length() > 0) params.setParam("bq", bq); // a boost query that moves double content to the back - if (bf.length() > 0) params.setParam(ranking.getMethod() == Ranking.BoostFunctionMode.add ? "bf" : "boost", bf); // a boost function extension, see http://wiki.apache.org/solr/ExtendedDisMax#bf_.28Boost_Function.2C_additive.29 + if (bq.length() > 0) params.setParam("bq", bq); + if (bf.length() > 0) params.setParam("boost", bf); // a boost function extension, see http://wiki.apache.org/solr/ExtendedDisMax#bf_.28Boost_Function.2C_additive.29 params.setStart(this.offset); params.setRows(this.itemsPerPage); params.setFacet(false);