Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
Fixed loss of "meanCount" search param when using facets or page buttons
luccioman0cdee4e26a74
diff --git a/htroot/yacysearch.java b/htroot/yacysearch.javaindex 0e5bf9c57..3c61bfe3a 100644--- a/htroot/yacysearch.java+++ b/htroot/yacysearch.java@@ -296,6 +296,9 @@ public class yacysearch {final boolean strictContentDom = !Boolean.FALSE.toString().equalsIgnoreCase(post.get("strictContentDom",sb.getConfig(SwitchboardConstants.SEARCH_STRICT_CONTENT_DOM,String.valueOf(SwitchboardConstants.SEARCH_STRICT_CONTENT_DOM_DEFAULT))));++ /* Maximum number of suggestions to display in the first results page */+ final int meanMax = post.getInt("meanCount", 0);// check the search trackerTreeSet<Long> trackerHandles = sb.localSearchTracker.get(client);@@ -699,6 +702,7 @@ public class yacysearch {lat, lon, rad,sb.getConfigArray("search.navigation", ""));theQuery.setStrictContentDom(strictContentDom);+ theQuery.setMaxSuggestions(meanMax);theQuery.setStandardFacetsMaxCount(sb.getConfigInt(SwitchboardConstants.SEARCH_NAVIGATION_MAXCOUNT,QueryParams.FACETS_STANDARD_MAXCOUNT_DEFAULT));theQuery.setDateFacetMaxCount(sb.getConfigInt(SwitchboardConstants.SEARCH_NAVIGATION_DATES_MAXCOUNT,@@ -791,10 +795,10 @@ public class yacysearch {AccessTracker.add(AccessTracker.Location.local, theQuery, theSearch.getResultCount());// check suggestions- final int meanMax = (post != null) ? post.getInt("meanCount", 0) : 0;prop.put("meanCount", meanMax);- if ( meanMax > 0 && !json && !rss) {+ /* Suggestions ("Did you mean") are only provided in the first html results page */+ if ( meanMax > 0 && startRecord ==0 && !json && !rss) {final DidYouMean didYouMean = new DidYouMean(indexSegment, querystring);final Iterator<StringBuilder> meanIt = didYouMean.getSuggestions(100, 5, sb.index.fulltext().collectionSize() < 2000000).iterator();int meanCount = 0;diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.javaindex 62922428b..07ea01abd 100644--- a/htroot/yacysearchitem.java+++ b/htroot/yacysearchitem.java@@ -549,7 +549,8 @@ public class yacysearchitem {final String actionLinkPrefix = linkBuilder.append("yacysearch.html?query=").append(origQ.replace(' ', '+')).append("&Enter=Search&count=").append(theSearch.query.itemsPerPage()).append("&offset=").append((theSearch.query.neededResults() - theSearch.query.itemsPerPage())).append("&resource=")- .append(resource).append("&time=3").append("auth").toString();+ .append(resource).append("&time=3").append("&meanCount=").append(theSearch.query.getMaxSuggestions())+ .append("&auth").toString();linkBuilder.setLength(0);String encodedURLString;diff --git a/source/net/yacy/search/query/QueryParams.java b/source/net/yacy/search/query/QueryParams.javaindex 913ed766d..b67e698db 100644--- a/source/net/yacy/search/query/QueryParams.java+++ b/source/net/yacy/search/query/QueryParams.java@@ -158,6 +158,12 @@ public final class QueryParams {*/private boolean strictContentDom = false;+ /**+ * The maximum number of suggestions ("Did you mean") to display at the top of+ * the first search results page+ */+ private int maxSuggestions = 0;+public final String targetlang;protected final Collection<Tagging.Metatag> metatags;public final Searchdom domType;@@ -419,6 +425,23 @@ public final class QueryParams {public void setStrictContentDom(final boolean strictContentDom) {this.strictContentDom = strictContentDom;}++ /**+ * @return The maximum number of suggestions ("Did you mean") to display at the+ * top of the first search results page+ */+ public int getMaxSuggestions() {+ return this.maxSuggestions;+ }++ /**+ * @param maxSuggestions+ * The maximum number of suggestions ("Did you mean") to display at+ * the top of the first search results page+ */+ public void setMaxSuggestions(final int maxSuggestions) {+ this.maxSuggestions = maxSuggestions;+ }public static HandleSet hashes2Set(final String query) {final HandleSet keyhashes = new RowHandleSet(WordReferenceRow.urlEntryRow.primaryKeyLength, WordReferenceRow.urlEntryRow.objectOrder, 0);@@ -871,6 +894,9 @@ public final class QueryParams {context.append(this.inlink).append(asterisk);context.append(this.lat).append(asterisk).append(this.lon).append(asterisk).append(this.radius).append(asterisk);context.append(this.snippetCacheStrategy == null ? "null" : this.snippetCacheStrategy.name());++ // Note : this.maxSuggestions search parameter do not need to be part of this id, as it has no impact on results themselves+String result = context.toString();if (anonymized) {this.idCacheAnon = result;@@ -1064,6 +1090,9 @@ public final class QueryParams {sb.append("&strictContentDom=");sb.append(String.valueOf(theQuery.isStrictContentDom()));++ sb.append("&meanCount=");+ sb.append(theQuery.getMaxSuggestions());sb.append("&former=");sb.append(theQuery.getQueryGoal().getQueryString(true));