RankingSolr: display only available or configured boost fields

pull/1/head
reger 10 years ago
parent fe537679de
commit d65e3f2b53

@ -83,7 +83,7 @@
<fieldset> <fieldset>
<input type="hidden" name="profileNr" value="#[profileNr]#" /> <input type="hidden" name="profileNr" value="#[profileNr]#" />
<legend>Solr Boosts</legend> <legend>Solr Boosts</legend>
This is the set of searchable fields. Entries without a boost value are not searched. Boost values make hits inside the corresponding field more important. This is the set of searchable fields (see <a href="IndexSchema_p.html">YaCy Solr Schema</a>). Entries without a boost value are not searched. Boost values make hits inside the corresponding field more important.
<dl style="margin:0;">#{boosts}# <dl style="margin:0;">#{boosts}#
<dt style="width:260px;margin:0;padding:0;height:1.8em;"><label for="boost_#[field]#">#[field]#</label> <dt style="width:260px;margin:0;padding:0;height:1.8em;"><label for="boost_#[field]#">#[field]#</label>
<input type="checkbox" id="#[field]#" name="#[field]#"#(checked)#:: checked="checked"#(/checked)# <input type="checkbox" id="#[field]#" name="#[field]#"#(checked)#:: checked="checked"#(/checked)#

@ -26,6 +26,7 @@ import net.yacy.cora.protocol.RequestHeader;
import net.yacy.search.Switchboard; import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants; import net.yacy.search.SwitchboardConstants;
import net.yacy.search.query.SearchEventCache; import net.yacy.search.query.SearchEventCache;
import net.yacy.search.schema.CollectionConfiguration;
import net.yacy.search.schema.CollectionSchema; import net.yacy.search.schema.CollectionSchema;
import net.yacy.server.serverObjects; import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch; import net.yacy.server.serverSwitch;
@ -125,22 +126,25 @@ public class RankingSolr_p {
final serverObjects prop = new serverObjects(); final serverObjects prop = new serverObjects();
int i = 0; int i = 0;
Ranking ranking = sb.index.fulltext().getDefaultConfiguration().getRanking(profileNr); CollectionConfiguration colcfg = sb.index.fulltext().getDefaultConfiguration();
Ranking ranking = colcfg.getRanking(profileNr);
for (SchemaDeclaration field: CollectionSchema.values()) { for (SchemaDeclaration field: CollectionSchema.values()) {
if (!field.isSearchable()) continue; if (!field.isSearchable()) continue;
prop.put("boosts_" + i + "_field", field.getSolrFieldName());
Float boost = ranking.getFieldBoost(field); Float boost = ranking.getFieldBoost(field);
if (boost == null || boost.floatValue() <= 0.0f) { if (boost != null || colcfg.contains(field)) { // show only available or configured boost fields
prop.put("boosts_" + i + "_checked", 0); prop.put("boosts_" + i + "_field", field.getSolrFieldName());
prop.put("boosts_" + i + "_boost", ""); if (boost == null || boost.floatValue() <= 0.0f) {
prop.put("boosts_" + i + "_notinindexwarning", "0"); prop.put("boosts_" + i + "_checked", 0);
} else { prop.put("boosts_" + i + "_boost", "");
prop.put("boosts_" + i + "_checked", 1); prop.put("boosts_" + i + "_notinindexwarning", "0");
prop.put("boosts_" + i + "_boost", boost.toString()); } else {
prop.put("boosts_" + i + "_notinindexwarning", (sb.index.fulltext().getDefaultConfiguration().contains(field.name())? "0" : "1") ); prop.put("boosts_" + i + "_checked", 1);
prop.put("boosts_" + i + "_boost", boost.toString());
prop.put("boosts_" + i + "_notinindexwarning", (colcfg.contains(field.name()) ? "0" : "1"));
}
prop.putHTML("boosts_" + i + "_comment", field.getComment());
i++;
} }
prop.putHTML("boosts_" + i + "_comment", field.getComment());
i++;
} }
prop.put("boosts", i); prop.put("boosts", i);
prop.put(CommonParams.FQ, ranking.getFilterQuery()); prop.put(CommonParams.FQ, ranking.getFilterQuery());

Loading…
Cancel
Save