when selecting collections in navigation, do show the un-selected

collections in search result. When selecting one of them in another
search, switch off the previously selected collection. This actually
turns the collection navigation modifier into a radio-button like
behaviour
pull/1/head
Michael Peter Christen 10 years ago
parent 1de9b21c65
commit 2e88028c1a

@ -275,7 +275,7 @@ public class yacysearchtrailer {
nav="";
}
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, true).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 + "_nl", 1);

@ -334,17 +334,18 @@ public class QueryModifier {
s = s.trim();
if (s.length() > 0) sites.add(s);
}
StringBuilder filterQuery = new StringBuilder(20);
StringBuilder fq = new StringBuilder(20);
if (sites.size() > 1) {
filterQuery.append('(').append(CollectionSchema.collection_sxt.getSolrFieldName()).append(":\"").append(sites.get(0)).append('\"');
fq.append('(').append(CollectionSchema.collection_sxt.getSolrFieldName()).append(":\"").append(sites.get(0)).append('\"');
for (int i = 1; i < sites.size(); i++) {
filterQuery.append(" OR ").append(CollectionSchema.collection_sxt.getSolrFieldName()).append(":\"").append(sites.get(i)).append('\"');
fq.append(" OR ").append(CollectionSchema.collection_sxt.getSolrFieldName()).append(":\"").append(sites.get(i)).append('\"');
}
filterQuery.append(')');
fq.append(')');
} else if (sites.size() == 1) {
filterQuery.append(CollectionSchema.collection_sxt.getSolrFieldName()).append(":\"").append(sites.get(0)).append('\"');
fq.append(CollectionSchema.collection_sxt.getSolrFieldName()).append(":\"").append(sites.get(0)).append('\"');
}
return filterQuery.toString();
if (fq.length() > 0) fq.insert(0, "{!tag=" + CollectionSchema.collection_sxt.getSolrFieldName() + "}");
return fq.toString();
}
public static String parseOnExpression(String onDescription) {

@ -453,7 +453,7 @@ public final class QueryParams {
params.setFacetLimit(FACETS_STANDARD_MAXCOUNT);
params.setFacetSort(FacetParams.FACET_SORT_COUNT);
params.setParam(FacetParams.FACET_METHOD, FacetParams.FACET_METHOD_fcs);
for (String field: this.facetfields) params.addFacetField(field); // params.addFacetField("{!ex=" + field + "}" + field);
for (String field: this.facetfields) params.addFacetField("{!ex=" + field + "}" + field); // params.addFacetField("{!ex=" + field + "}" + field);
if (this.facetfields.contains(CollectionSchema.dates_in_content_dts.name())) {
params.setParam("facet.range", CollectionSchema.dates_in_content_dts.name());
@SuppressWarnings({ "static-access", "deprecation" })
@ -688,25 +688,25 @@ public final class QueryParams {
*/
public static StringBuilder navurlBase(final RequestHeader.FileType ext, final QueryParams theQuery, final String newModifier, boolean newModifierReplacesOld) {
final StringBuilder sb = new StringBuilder(120);
StringBuilder sb = new StringBuilder(120);
sb.append("/yacysearch.");
sb.append(ext.name().toLowerCase());
sb.append("?query=");
sb.append(theQuery.getQueryGoal().getQueryString(true));
if (newModifier == null) {
sb.append(theQuery.getQueryGoal().getQueryString(true));
if (!theQuery.modifier.isEmpty()) sb.append("+" + theQuery.modifier.toString());
} else {
if (newModifier.isEmpty()) {
sb.append(theQuery.getQueryGoal().getQueryString(true));
} else {
if (!newModifier.isEmpty()) {
if (!theQuery.modifier.isEmpty()) sb.append("+" + theQuery.modifier.toString());
if (newModifierReplacesOld) {
sb.append(newModifier);
} else {
sb.append(theQuery.queryGoal.getQueryString(true));
if (!theQuery.modifier.isEmpty()) sb.append("+" + theQuery.modifier.toString());
sb.append("+" + newModifier);
int nmpi = newModifier.indexOf("%3A");
String nmp = newModifier.substring(0, nmpi) + ":";
int i = sb.indexOf(nmp);
if (i > 0) sb = new StringBuilder(sb.substring(0, i).trim());
if (sb.charAt(sb.length() - 1) == '+') sb.setLength(sb.length() - 1);
}
sb.append("+" + newModifier);
}
}

Loading…
Cancel
Save