Permalink
Browse files

Fixed loss of "meanCount" search param when using facets or page buttons

Then on new search queries, no suggestions at all could be displayed.
  • Loading branch information...
luccioman committed Feb 8, 2018
1 parent 117a859 commit 0cdee4e26a74f26602295d0d01393ed82a15eba7
Showing with 37 additions and 3 deletions.
  1. +6 −2 htroot/yacysearch.java
  2. +2 −1 htroot/yacysearchitem.java
  3. +29 −0 source/net/yacy/search/query/QueryParams.java
@@ -296,6 +296,9 @@ public static serverObjects respond(
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 tracker
TreeSet<Long> trackerHandles = sb.localSearchTracker.get(client);
@@ -699,6 +702,7 @@ public static serverObjects respond(
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 static serverObjects respond(
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;
@@ -549,7 +549,8 @@ private static void addAuthorizedActions(final Switchboard sb, final serverObjec
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;
@@ -158,6 +158,12 @@ public String toString() {
*/
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 boolean isStrictContentDom() {
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 String id(final boolean anonymized) {
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 @@ protected static void appendNavUrlQueryParams(final StringBuilder sb, final Quer
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));

0 comments on commit 0cdee4e

Please sign in to comment.