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

Then on new search queries, no suggestions at all could be displayed.
pull/167/head
luccioman 7 years ago
parent 117a859879
commit 0cdee4e26a

@ -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 tracker
TreeSet<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;

@ -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;

@ -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));

Loading…
Cancel
Save