Skip to content

Commit

Permalink
altered clac. of search result items per page to display
Browse files Browse the repository at this point in the history
taking the existing limits into account but make it consistent with search option screen for admin and public user
changes:
  - configured default number of items per page (ConfigPortal_p.html) is used as is (no hardcoded limit)
  - otherwise requests are limited to 100 results per page ( = search option, index.html)
      (this basically is the major change, inc. limit from 20 to 100 for public user)
P.S. - the older grant of more (1000), if no online snippet calculation, is kept (for the time being)

see http://mantis.tokeek.de/view.php?id=627
  • Loading branch information
reger committed Jan 13, 2016
1 parent abd8ecb commit 4765e37
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion defaults/yacy.init
Expand Up @@ -813,7 +813,7 @@ search.audio = false
search.video = false
search.app = false

# number of search results displayed by default
# number of search results per page displayed by default
search.items = 10

# target for search results; this is the href target attribute inside every search result link
Expand Down
2 changes: 1 addition & 1 deletion htroot/ConfigPortal.html
Expand Up @@ -82,7 +82,7 @@ <h2>Integration of a Search Portal</h2>
</dd>

<dt>Default maximum number of results per page</dt>
<dd><input type="text" name="maximumRecords" value="#[maximumRecords]#" size="3" /> <small>max = 100 (with CACHEONLY=5000)</small></dd>
<dd><input type="text" name="maximumRecords" value="#[maximumRecords]#" size="3" /></dd>

<dt>Default index.html Page (by forwarder)</dt>
<dd><input type="text" name="indexForward" value="#[indexForward]#" size="60" /></dd>
Expand Down
17 changes: 9 additions & 8 deletions htroot/yacysearch.java
Expand Up @@ -220,14 +220,15 @@ public static serverObjects respond(

// collect search attributes

int itemsPerPage =
Math.min(
(authenticated)
? (snippetFetchStrategy != null && snippetFetchStrategy.isAllowedToFetchOnline()
? 100
: 5000) : (snippetFetchStrategy != null
&& snippetFetchStrategy.isAllowedToFetchOnline() ? 20 : 1000),
post.getInt("maximumRecords", post.getInt("count", post.getInt("rows", sb.getConfigInt(SwitchboardConstants.SEARCH_ITEMS, 10))))); // SRU syntax with old property as alternative
// check an determine items per page (max of [100 or configured default]}
final int defaultItemsPerPage = sb.getConfigInt(SwitchboardConstants.SEARCH_ITEMS, 10);
int itemsPerPage = post.getInt("maximumRecords", post.getInt("count", post.getInt("rows", defaultItemsPerPage))); // requested or default // SRU syntax with old property as alternative
// whatever admin has set as default, that's always ok
if (itemsPerPage > defaultItemsPerPage && itemsPerPage > 100) { // if above hardcoded 100 limit restrict request (except default allows more)
// search option (index.html) offers up to 100 (that defines the lower limit available to request)
itemsPerPage = Math.max((snippetFetchStrategy != null && snippetFetchStrategy.isAllowedToFetchOnline() ? 100 : 1000), defaultItemsPerPage);
}

int startRecord = post.getInt("startRecord", post.getInt("offset", post.getInt("start", 0)));

final boolean indexof = (post != null && post.get("indexof", "").equals("on"));
Expand Down

0 comments on commit 4765e37

Please sign in to comment.