added an expansion option to search facets on result page:

- if less or equal of 8 facet options are present, they are shown by
default
- if more facet options are present, they are hidden
To view or hide all facets, just click on the facet header bar
pull/1/head
Michael Peter Christen 10 years ago
parent 5789c96292
commit f9ba50379d

@ -143,60 +143,78 @@ show search results for "#[query]#" on map</a>
</script> </script>
#(/nav-dates)# #(/nav-dates)#
<script>
function toggleVisibility(name, count) {
if (document.getElementById(name + "_0").style.display == "none") {
for (i = 0; i < count; i++) document.getElementById(name + "_" + i).style="display:block";
document.getElementById("chevron-" + name).className = "glyphicon glyphicon-chevron-up";
} else {
for (i = 0; i < count; i++) document.getElementById(name + "_" + i).style="display:none";
document.getElementById("chevron-" + name).className = "glyphicon glyphicon-chevron-down";
}
}
</script>
#(nav-domains)#:: #(nav-domains)#::
<ul class="nav nav-sidebar menugroup"> <ul class="nav nav-sidebar menugroup">
<li><h3>Provider</h3></li> <li><h3 onclick="toggleVisibility('domains', #[count]#);">Provider [#[count]#] <span style="float:right" id="chevron-domains" class="glyphicon glyphicon-chevron-down" title="click to expand facet"></span></h3></li>
#{element}# #{element}#
<li><a href="#[url]#" class="MenuItemLink"><input type="checkbox" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/> #[name]# (#[count]#)</a></li> <li style="display:none" id="#[id]#"><a href="#[url]#" class="MenuItemLink"><input type="checkbox" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/> #[name]# (#[count]#)</a></li>
#{/element}#</ul> #{/element}#</ul>
<script>if (#[count]# <= 8) toggleVisibility('domains', #[count]#);</script>
#(/nav-domains)# #(/nav-domains)#
#(nav-filetypes)#:: #(nav-filetypes)#::
<ul class="nav nav-sidebar menugroup"> <ul class="nav nav-sidebar menugroup">
<li><h3>Filetype</h3></li> <li><h3 onclick="toggleVisibility('filetypes', #[count]#);">Filetype [#[count]#] <span style="float:right" id="chevron-filetypes" class="glyphicon glyphicon-chevron-down" title="click to expand facet"></span></h3></li>
#{element}# #{element}#
<li><a href="#[url]#" class="MenuItemLink"><input type="checkbox" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/> #[name]# (#[count]#)</a></li> <li style="display:none" id="#[id]#"><a href="#[url]#" class="MenuItemLink"><input type="checkbox" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/> #[name]# (#[count]#)</a></li>
#{/element}#</ul> #{/element}#</ul>
<script>if (#[count]# <= 8) toggleVisibility('filetypes', #[count]#);</script>
#(/nav-filetypes)# #(/nav-filetypes)#
#(nav-languages)#:: #(nav-languages)#::
<ul class="nav nav-sidebar menugroup"> <ul class="nav nav-sidebar menugroup">
<li><h3>Language</h3></li> <li><h3 onclick="toggleVisibility('languages', #[count]#);">Language [#[count]#] <span style="float:right" id="chevron-languages" class="glyphicon glyphicon-chevron-down" title="click to expand facet"></span></h3></li>
#{element}# #{element}#
<li><a href="#[url]#" class="MenuItemLink"><input type="checkbox" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/> #[name]# (#[count]#)</a></li> <li style="display:none" id="#[id]#"><a href="#[url]#" class="MenuItemLink"><input type="checkbox" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/> #[name]# (#[count]#)</a></li>
#{/element}#</ul> #{/element}#</ul>
<script>if (#[count]# <= 8) toggleVisibility('languages', #[count]#);</script>
#(/nav-languages)# #(/nav-languages)#
#(nav-namespace)#:: #(nav-namespace)#::
<ul class="nav nav-sidebar menugroup"> <ul class="nav nav-sidebar menugroup">
<li><h3>Name Space</h3></li> <li><h3 onclick="toggleVisibility('namespace', #[count]#);">Name Space [#[count]#] <span style="float:right" id="chevron-namespace" class="glyphicon glyphicon-chevron-down" title="click to expand facet"></span></h3></li>
#{element}# #{element}#
<li><a href="#[url]#" class="MenuItemLink"><input type="checkbox" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/> #[name]# (#[count]#)</a></li> <li style="display:none" id="#[id]#"><a href="#[url]#" class="MenuItemLink"><input type="checkbox" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/> #[name]# (#[count]#)</a></li>
#{/element}#</ul> #{/element}#</ul>
<script>if (#[count]# <= 8) toggleVisibility('namespace', #[count]#);</script>
#(/nav-namespace)# #(/nav-namespace)#
#(nav-authors)#:: #(nav-authors)#::
<ul class="nav nav-sidebar menugroup"> <ul class="nav nav-sidebar menugroup">
<li><h3>Author</h3></li> <li><h3 onclick="toggleVisibility('authors', #[count]#);">Author [#[count]#] <span style="float:right" id="chevron-authors" class="glyphicon glyphicon-chevron-down" title="click to expand facet"></span></h3></li>
#{element}# #{element}#
<li><a href="#[url]#" class="MenuItemLink"><input type="checkbox" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/> #[name]# (#[count]#)</a></li> <li style="display:none" id="#[id]#"><a href="#[url]#" class="MenuItemLink"><input type="checkbox" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/> #[name]# (#[count]#)</a></li>
#{/element}#</ul> #{/element}#</ul>
<script>if (#[count]# <= 8) toggleVisibility('authors', #[count]#);</script>
#(/nav-authors)# #(/nav-authors)#
#(nav-collections)#:: #(nav-collections)#::
<ul class="nav nav-sidebar menugroup"> <ul class="nav nav-sidebar menugroup">
<li><h3>Collection</h3></li> <li><h3 onclick="toggleVisibility('collections', #[count]#);">Collection [#[count]#] <span style="float:right" id="chevron-collections" class="glyphicon glyphicon-chevron-down" title="click to expand facet"></span></h3></li>
#{element}# #{element}#
<li><a href="#[url]#" class="MenuItemLink"><input type="checkbox" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/> #[name]# (#[count]#)</a></li> <li style="display:none" id="#[id]#"><a href="#[url]#" class="MenuItemLink"><input type="checkbox" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/> #[name]# (#[count]#)</a></li>
#{/element}#</ul> #{/element}#</ul>
<script>if (#[count]# <= 8) toggleVisibility('collections', #[count]#);</script>
#(/nav-collections)# #(/nav-collections)#
#{nav-vocabulary}# #{nav-vocabulary}#
<ul class="nav nav-sidebar menugroup"> <ul class="nav nav-sidebar menugroup">
<li><h3>#[navname]#</h3></li> <li><h3 onclick="toggleVisibility('vocabulary_#[navname]#', #[count]#);">#[navname]# [#[count]#] <span style="float:right" id="chevron-vocabulary_#[navname]#" class="glyphicon glyphicon-chevron-down" title="click to expand facet"></span></h3></li>
#{element}# #{element}#
<li><a href="#[url]#" class="MenuItemLink"><input type="checkbox" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/> #[name]# (#[count]#)</a></li> <li style="display:none" id="#[id]#"><a href="#[url]#" class="MenuItemLink"><input type="checkbox" onchange="window.location.href='#[url]#'"#(on)# checked="checked"::#(/on)#/> #[name]# (#[count]#)</a></li>
#{/element}#</ul> #{/element}#</ul>
<script>if (#[count]# <= 8) toggleVisibility('vocabulary_#[navname]#', #[count]#);</script>
#{/nav-vocabulary}# #{/nav-vocabulary}#
#(nav-about)#:: #(nav-about)#::

@ -124,6 +124,7 @@ public class yacysearchtrailer {
} }
prop.put(fileType, "nav-namespace_element_" + i + "_name", name); prop.put(fileType, "nav-namespace_element_" + i + "_name", name);
prop.put(fileType, "nav-namespace_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, nav, false).toString()); prop.put(fileType, "nav-namespace_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, nav, false).toString());
prop.put(fileType, "nav-namespace_element_" + i + "_id", "namespace_" + i);
prop.put("nav-namespace_element_" + i + "_count", count); prop.put("nav-namespace_element_" + i + "_count", count);
prop.put("nav-namespace_element_" + i + "_nl", 1); prop.put("nav-namespace_element_" + i + "_nl", 1);
i++; i++;
@ -134,7 +135,7 @@ public class yacysearchtrailer {
if (pos == 1 && neg == 0) prop.put("nav-namespace", 0); // this navigation is not useful if (pos == 1 && neg == 0) prop.put("nav-namespace", 0); // this navigation is not useful
} }
// host navigators // domain navigators
final ScoreMap<String> hostNavigator = theSearch.hostNavigator; final ScoreMap<String> hostNavigator = theSearch.hostNavigator;
if (hostNavigator == null || hostNavigator.isEmpty()) { if (hostNavigator == null || hostNavigator.isEmpty()) {
prop.put("nav-domains", 0); prop.put("nav-domains", 0);
@ -160,11 +161,13 @@ public class yacysearchtrailer {
} }
prop.put(fileType, "nav-domains_element_" + i + "_name", name); prop.put(fileType, "nav-domains_element_" + i + "_name", name);
prop.put(fileType, "nav-domains_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, nav, false).toString()); prop.put(fileType, "nav-domains_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, nav, false).toString());
prop.put(fileType, "nav-domains_element_" + i + "_id", "domains_" + i);
prop.put("nav-domains_element_" + i + "_count", count); prop.put("nav-domains_element_" + i + "_count", count);
prop.put("nav-domains_element_" + i + "_nl", 1); prop.put("nav-domains_element_" + i + "_nl", 1);
i++; i++;
} }
prop.put("nav-domains_element", i); prop.put("nav-domains_element", i);
prop.put("nav-domains_count", i);
i--; i--;
prop.put("nav-domains_element_" + i + "_nl", 0); prop.put("nav-domains_element_" + i + "_nl", 0);
if (pos == 1 && neg == 0) prop.put("nav-domains", 0); // this navigation is not useful if (pos == 1 && neg == 0) prop.put("nav-domains", 0); // this navigation is not useful
@ -197,11 +200,13 @@ public class yacysearchtrailer {
String longname = ISO639.country(name); String longname = ISO639.country(name);
prop.put(fileType, "nav-languages_element_" + i + "_name", longname == null ? name : longname); prop.put(fileType, "nav-languages_element_" + i + "_name", longname == null ? name : longname);
prop.put(fileType, "nav-languages_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, nav, false).toString()); prop.put(fileType, "nav-languages_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, nav, false).toString());
prop.put(fileType, "nav-languages_element_" + i + "_id", "languages_" + i);
prop.put("nav-languages_element_" + i + "_count", count); prop.put("nav-languages_element_" + i + "_count", count);
prop.put("nav-languages_element_" + i + "_nl", 1); prop.put("nav-languages_element_" + i + "_nl", 1);
i++; i++;
} }
prop.put("nav-languages_element", i); prop.put("nav-languages_element", i);
prop.put("nav-languages_count", i);
i--; i--;
prop.put("nav-languages_element_" + i + "_nl", 0); prop.put("nav-languages_element_" + i + "_nl", 0);
if (pos == 1 && neg == 0) prop.put("nav-languages", 0); // this navigation is not useful if (pos == 1 && neg == 0) prop.put("nav-languages", 0); // this navigation is not useful
@ -232,11 +237,13 @@ public class yacysearchtrailer {
} }
prop.put(fileType, "nav-authors_element_" + i + "_name", name); prop.put(fileType, "nav-authors_element_" + i + "_name", name);
prop.put(fileType, "nav-authors_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, nav, false).toString()); prop.put(fileType, "nav-authors_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, nav, false).toString());
prop.put(fileType, "nav-authors_element_" + i + "_id", "authors_" + i);
prop.put("nav-authors_element_" + i + "_count", count); prop.put("nav-authors_element_" + i + "_count", count);
prop.put("nav-authors_element_" + i + "_nl", 1); prop.put("nav-authors_element_" + i + "_nl", 1);
i++; i++;
} }
prop.put("nav-authors_element", i); prop.put("nav-authors_element", i);
prop.put("nav-authors_count", i);
i--; i--;
prop.put("nav-authors_element_" + i + "_nl", 0); prop.put("nav-authors_element_" + i + "_nl", 0);
if (pos == 1 && neg == 0) { if (pos == 1 && neg == 0) {
@ -269,11 +276,13 @@ public class yacysearchtrailer {
} }
prop.put(fileType, "nav-collections_element_" + i + "_name", name); prop.put(fileType, "nav-collections_element_" + i + "_name", name);
prop.put(fileType, "nav-collections_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, nav, false).toString()); prop.put(fileType, "nav-collections_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, nav, false).toString());
prop.put(fileType, "nav-collections_element_" + i + "_id", "collections_" + i);
prop.put("nav-collections_element_" + i + "_count", count); prop.put("nav-collections_element_" + i + "_count", count);
prop.put("nav-collections_element_" + i + "_nl", 1); prop.put("nav-collections_element_" + i + "_nl", 1);
i++; i++;
} }
prop.put("nav-collections_element", i); prop.put("nav-collections_element", i);
prop.put("nav-collections_count", i);
i--; i--;
prop.put("nav-collections_element_" + i + "_nl", 0); prop.put("nav-collections_element_" + i + "_nl", 0);
if (pos == 1 && neg == 0) prop.put("nav-collections", 0); // this navigation is not useful if (pos == 1 && neg == 0) prop.put("nav-collections", 0); // this navigation is not useful
@ -318,6 +327,7 @@ public class yacysearchtrailer {
i++; i++;
} }
prop.put("nav-topics_element", i); prop.put("nav-topics_element", i);
prop.put("nav-topics_count", i);
i--; i--;
prop.put("nav-topics_element_" + i + "_nl", 0); prop.put("nav-topics_element_" + i + "_nl", 0);
} }
@ -366,6 +376,7 @@ public class yacysearchtrailer {
if (oldProtocolModifier != null && oldProtocolModifier.length() > 0) theSearch.query.modifier.add(oldProtocolModifier.startsWith("/") ? oldProtocolModifier : "/" + oldProtocolModifier); if (oldProtocolModifier != null && oldProtocolModifier.length() > 0) theSearch.query.modifier.add(oldProtocolModifier.startsWith("/") ? oldProtocolModifier : "/" + oldProtocolModifier);
theSearch.query.getQueryGoal().query_original = oldQuery; theSearch.query.getQueryGoal().query_original = oldQuery;
prop.put("nav-protocols_element", i); prop.put("nav-protocols_element", i);
prop.put("nav-protocols_count", i);
i--; i--;
prop.put("nav-protocols_element_" + i + "_nl", 0); prop.put("nav-protocols_element_" + i + "_nl", 0);
if (pos == 1 && neg == 0) prop.put("nav-protocols", 0); // this navigation is not useful if (pos == 1 && neg == 0) prop.put("nav-protocols", 0); // this navigation is not useful
@ -418,6 +429,7 @@ public class yacysearchtrailer {
i++; i++;
} }
prop.put("nav-dates_element", i); prop.put("nav-dates_element", i);
prop.put("nav-dates_count", i);
i--; i--;
prop.put("nav-dates_element_" + i + "_nl", 0); prop.put("nav-dates_element_" + i + "_nl", 0);
if (pos == 1 && neg == 0) prop.put("nav-dates", 0); // this navigation is not useful if (pos == 1 && neg == 0) prop.put("nav-dates", 0); // this navigation is not useful
@ -450,11 +462,13 @@ public class yacysearchtrailer {
} }
prop.put(fileType, "nav-filetypes_element_" + i + "_name", name); prop.put(fileType, "nav-filetypes_element_" + i + "_name", name);
prop.put(fileType, "nav-filetypes_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, nav, false).toString()); prop.put(fileType, "nav-filetypes_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, nav, false).toString());
prop.put(fileType, "nav-filetypes_element_" + i + "_id", "filetypes_" + i);
prop.put("nav-filetypes_element_" + i + "_count", count); prop.put("nav-filetypes_element_" + i + "_count", count);
prop.put("nav-filetypes_element_" + i + "_nl", 1); prop.put("nav-filetypes_element_" + i + "_nl", 1);
i++; i++;
} }
prop.put("nav-filetypes_element", i); prop.put("nav-filetypes_element", i);
prop.put("nav-filetypes_count", i);
i--; i--;
prop.put("nav-filetypes_element_" + i + "_nl", 0); prop.put("nav-filetypes_element_" + i + "_nl", 0);
if (pos == 1 && neg == 0) prop.put("nav-filetypes", 0); // this navigation is not useful if (pos == 1 && neg == 0) prop.put("nav-filetypes", 0); // this navigation is not useful
@ -488,11 +502,13 @@ public class yacysearchtrailer {
} }
prop.put(fileType, "nav-vocabulary_" + navvoccount + "_element_" + i + "_name", name); prop.put(fileType, "nav-vocabulary_" + navvoccount + "_element_" + i + "_name", name);
prop.put(fileType, "nav-vocabulary_" + navvoccount + "_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, nav, false).toString()); prop.put(fileType, "nav-vocabulary_" + navvoccount + "_element_" + i + "_url", QueryParams.navurl(fileType, 0, theSearch.query, nav, false).toString());
prop.put(fileType, "nav-vocabulary_" + navvoccount + "_element_" + i + "_id", "vocabulary_" + navname + "_" + i);
prop.put("nav-vocabulary_" + navvoccount + "_element_" + i + "_count", count); prop.put("nav-vocabulary_" + navvoccount + "_element_" + i + "_count", count);
prop.put("nav-vocabulary_" + navvoccount + "_element_" + i + "_nl", 1); prop.put("nav-vocabulary_" + navvoccount + "_element_" + i + "_nl", 1);
i++; i++;
} }
prop.put("nav-vocabulary_" + navvoccount + "_element", i); prop.put("nav-vocabulary_" + navvoccount + "_element", i);
prop.put("nav-vocabulary_" + navvoccount + "_count", i);
i--; i--;
prop.put("nav-vocabulary_" + navvoccount + "_element_" + i + "_nl", 0); prop.put("nav-vocabulary_" + navvoccount + "_element_" + i + "_nl", 0);
navvoccount++; navvoccount++;

@ -130,7 +130,7 @@ public class GSAsearchServlet extends HttpServlet {
// get a solr query string // get a solr query string
QueryGoal qg = new QueryGoal(originalQuery); QueryGoal qg = new QueryGoal(originalQuery);
StringBuilder solrQ = qg.collectionTextQueryString(sb.index.fulltext().getDefaultConfiguration(), 0, false); StringBuilder solrQ = qg.collectionTextQueryString(false);
post.put("defType", "edismax"); post.put("defType", "edismax");
post.put(CommonParams.Q, solrQ.toString()); post.put(CommonParams.Q, solrQ.toString());
post.put(CommonParams.ROWS, post.remove("num")); post.put(CommonParams.ROWS, post.remove("num"));

@ -141,7 +141,7 @@ public class SolrSelectServlet extends HttpServlet {
querystring = modifier.parse(querystring); querystring = modifier.parse(querystring);
modifier.apply(mmsp); modifier.apply(mmsp);
QueryGoal qg = new QueryGoal(querystring); QueryGoal qg = new QueryGoal(querystring);
StringBuilder solrQ = qg.collectionTextQueryString(sb.index.fulltext().getDefaultConfiguration(), profileNr, false); StringBuilder solrQ = qg.collectionTextQueryString(false);
mmsp.getMap().put(CommonParams.Q, new String[]{solrQ.toString()}); // sru patch mmsp.getMap().put(CommonParams.Q, new String[]{solrQ.toString()}); // sru patch
} }
String q = mmsp.get(CommonParams.Q, ""); String q = mmsp.get(CommonParams.Q, "");

@ -41,7 +41,6 @@ import net.yacy.document.parser.html.CharacterCoding;
import net.yacy.kelondro.data.word.Word; import net.yacy.kelondro.data.word.Word;
import net.yacy.kelondro.util.SetTools; import net.yacy.kelondro.util.SetTools;
import net.yacy.search.index.Segment; import net.yacy.search.index.Segment;
import net.yacy.search.schema.CollectionConfiguration;
import net.yacy.search.schema.CollectionSchema; import net.yacy.search.schema.CollectionSchema;
public class QueryGoal { public class QueryGoal {
@ -319,7 +318,7 @@ public class QueryGoal {
for (final byte[] b: blues) this.include_hashes.remove(b); for (final byte[] b: blues) this.include_hashes.remove(b);
} }
public StringBuilder collectionTextQueryString(CollectionConfiguration configuration, int rankingProfile, boolean noimages) { public StringBuilder collectionTextQueryString(boolean noimages) {
final StringBuilder q = new StringBuilder(80); final StringBuilder q = new StringBuilder(80);
// add filter to prevent that results come from failed urls // add filter to prevent that results come from failed urls

@ -75,8 +75,8 @@ import org.apache.solr.schema.TrieDateField;
public final class QueryParams { public final class QueryParams {
public static int FACETS_STANDARD_MAXCOUNT = 30; public static int FACETS_STANDARD_MAXCOUNT = 10000;
public static int FACETS_DATE_MAXCOUNT = 730; public static int FACETS_DATE_MAXCOUNT = 640;
public enum Searchdom { public enum Searchdom {
LOCAL, CLUSTER, GLOBAL; LOCAL, CLUSTER, GLOBAL;
@ -371,7 +371,7 @@ public final class QueryParams {
// construct query // construct query
final SolrQuery params = getBasicParams(getFacets); final SolrQuery params = getBasicParams(getFacets);
int rankingProfile = this.ranking.coeff_date == RankingProfile.COEFF_MAX ? 1 : (this.modifier.sitehash != null || this.modifier.sitehost != null) ? 2 : 0; int rankingProfile = this.ranking.coeff_date == RankingProfile.COEFF_MAX ? 1 : (this.modifier.sitehash != null || this.modifier.sitehost != null) ? 2 : 0;
params.setQuery(this.queryGoal.collectionTextQueryString(this.indexSegment.fulltext().getDefaultConfiguration(), rankingProfile, excludeintext_image).toString()); params.setQuery(this.queryGoal.collectionTextQueryString(excludeintext_image).toString());
Ranking actRanking = indexSegment.fulltext().getDefaultConfiguration().getRanking(rankingProfile); // for a by-date ranking select different ranking profile Ranking actRanking = indexSegment.fulltext().getDefaultConfiguration().getRanking(rankingProfile); // for a by-date ranking select different ranking profile
String fq = actRanking.getFilterQuery(); String fq = actRanking.getFilterQuery();

Loading…
Cancel
Save