diff options
| author | luccioman <luccioman@users.noreply.github.com> | 2017-09-25 09:19:08 +0200 |
|---|---|---|
| committer | luccioman <luccioman@users.noreply.github.com> | 2017-09-25 09:19:08 +0200 |
| commit | ef8aea7f8db9222ba437cd3ab28e330fd622ff92 (patch) | |
| tree | 07371b5cb1ac710cc228769635e2da609d5e0bb3 /htroot | |
| parent | 0b0980b36409168725aef3de787d97ae01e06b70 (diff) | |
Made the dates navigator max elements number user configurable.
Also used object properties on QueryParams instances, rather than using
mutable class (static) properties.
Diffstat (limited to 'htroot')
| -rw-r--r-- | htroot/ConfigSearchPage_p.html | 5 | ||||
| -rw-r--r-- | htroot/ConfigSearchPage_p.java | 22 | ||||
| -rw-r--r-- | htroot/IndexControlRWIs_p.java | 6 | ||||
| -rw-r--r-- | htroot/yacy/search.java | 4 | ||||
| -rw-r--r-- | htroot/yacysearch.java | 4 | ||||
| -rw-r--r-- | htroot/yacysearchtrailer.java | 10 |
6 files changed, 41 insertions, 10 deletions
diff --git a/htroot/ConfigSearchPage_p.html b/htroot/ConfigSearchPage_p.html index 7bd5b4eab..a95ab21ee 100644 --- a/htroot/ConfigSearchPage_p.html +++ b/htroot/ConfigSearchPage_p.html @@ -179,13 +179,16 @@ <input type="checkbox" name="search.navigation.date" value="true" #(search.navigation.date)#::checked="checked" #(/search.navigation.date)# /> Date Navigation + <label title="Maximum days number in the histogram. Beware that a large value may trigger high CPU loads both on the server and on the browser with large result sets.">Maximum range (in days) + <input type="number" name="search.navigation.dates.maxcount" value="#[search.navigation.dates.maxcount]#" min="6" max="2147483647"/> + </label> <link rel="stylesheet" href="env/morris.css"> <script src="js/raphael.min.js"></script> <script src="js/morris.js"></script> <script type="text/javascript" src="js/accessibleHistogram.js" charset="UTF-8"></script> <div id="graph" style="height:200px"></div> <script> -var solr= $.getJSON("solr/collection1/select?q=*:*&defType=edismax&start=0&rows=0&wt=json&facet=true&facet.field=dates_in_content_dts&facet.sort=index", function(data) { +var solr= $.getJSON("solr/collection1/select?q=*:*&defType=edismax&start=0&rows=0&wt=json&facet=true&facet.field=dates_in_content_dts&facet.sort=index&facet.limit=#[search.navigation.dates.maxcount]#", function(data) { dates_in_content_dts = data.facet_counts.facet_fields.dates_in_content_dts; var parsed = []; for (var i = 0; i < dates_in_content_dts.length; i = i + 2) { diff --git a/htroot/ConfigSearchPage_p.java b/htroot/ConfigSearchPage_p.java index b86b5879b..42312c5b8 100644 --- a/htroot/ConfigSearchPage_p.java +++ b/htroot/ConfigSearchPage_p.java @@ -104,11 +104,17 @@ public class ConfigSearchPage_p { if (nav.endsWith(",")) nav = nav.substring(0, nav.length() - 1); sb.setConfig("search.navigation", nav); // maxcount nav entries, default - int navmaxcnt = post.getInt("search.navigation.maxcount", QueryParams.FACETS_STANDARD_MAXCOUNT); + int navmaxcnt = post.getInt(SwitchboardConstants.SEARCH_NAVIGATION_MAXCOUNT, QueryParams.FACETS_STANDARD_MAXCOUNT_DEFAULT); if (navmaxcnt > 5) { sb.setConfig(SwitchboardConstants.SEARCH_NAVIGATION_MAXCOUNT, navmaxcnt); - if (navmaxcnt != QueryParams.FACETS_STANDARD_MAXCOUNT) QueryParams.FACETS_STANDARD_MAXCOUNT = navmaxcnt; } + + // maxcount dates navigator entries + int datesNavMaxCnt = post.getInt(SwitchboardConstants.SEARCH_NAVIGATION_DATES_MAXCOUNT, + QueryParams.FACETS_DATE_MAXCOUNT_DEFAULT); + if (datesNavMaxCnt > 5) { + sb.setConfig(SwitchboardConstants.SEARCH_NAVIGATION_DATES_MAXCOUNT, datesNavMaxCnt); + } } if (post.containsKey("add.nav")) { // button: add navigator plugin to ative list @@ -168,6 +174,12 @@ public class ConfigSearchPage_p { sb.setConfig("search.result.show.proxy", config.getProperty("search.result.show.proxy","false")); sb.setConfig("search.result.show.hostbrowser", config.getProperty("search.result.show.hostbrowser","true")); sb.setConfig("search.result.show.snapshots", config.getProperty("search.result.show.snapshots","true")); + sb.setConfig(SwitchboardConstants.SEARCH_NAVIGATION_MAXCOUNT, + config.getProperty(SwitchboardConstants.SEARCH_NAVIGATION_MAXCOUNT, + String.valueOf(QueryParams.FACETS_STANDARD_MAXCOUNT_DEFAULT))); + sb.setConfig(SwitchboardConstants.SEARCH_NAVIGATION_DATES_MAXCOUNT, + config.getProperty(SwitchboardConstants.SEARCH_NAVIGATION_DATES_MAXCOUNT, + String.valueOf(QueryParams.FACETS_DATE_MAXCOUNT_DEFAULT))); } } @@ -238,7 +250,11 @@ public class ConfigSearchPage_p { } prop.put("search.navigation.list", i); - prop.put("search.navigation.maxcount", sb.getConfigInt(SwitchboardConstants.SEARCH_NAVIGATION_MAXCOUNT, QueryParams.FACETS_STANDARD_MAXCOUNT)); + prop.put(SwitchboardConstants.SEARCH_NAVIGATION_MAXCOUNT, sb.getConfigInt( + SwitchboardConstants.SEARCH_NAVIGATION_MAXCOUNT, QueryParams.FACETS_STANDARD_MAXCOUNT_DEFAULT)); + + prop.put(SwitchboardConstants.SEARCH_NAVIGATION_DATES_MAXCOUNT, sb.getConfigInt( + SwitchboardConstants.SEARCH_NAVIGATION_DATES_MAXCOUNT, QueryParams.FACETS_DATE_MAXCOUNT_DEFAULT)); prop.put("about.headline", sb.getConfig("about.headline", "About")); prop.put("about.body", sb.getConfig("about.body", "")); diff --git a/htroot/IndexControlRWIs_p.java b/htroot/IndexControlRWIs_p.java index 6c80e4346..ebe894c80 100644 --- a/htroot/IndexControlRWIs_p.java +++ b/htroot/IndexControlRWIs_p.java @@ -679,7 +679,11 @@ public class IndexControlRWIs_p { sb.getRanking(), "",//userAgent 0.0d, 0.0d, 0.0d, - new String[0]); + new String[0]); + query.setStandardFacetsMaxCount(sb.getConfigInt(SwitchboardConstants.SEARCH_NAVIGATION_MAXCOUNT, + QueryParams.FACETS_STANDARD_MAXCOUNT_DEFAULT)); + query.setDateFacetMaxCount(sb.getConfigInt(SwitchboardConstants.SEARCH_NAVIGATION_DATES_MAXCOUNT, + QueryParams.FACETS_DATE_MAXCOUNT_DEFAULT)); final SearchEvent theSearch = SearchEventCache.getEvent(query, sb.peers, sb.tables, null, false, sb.loader, Integer.MAX_VALUE, Long.MAX_VALUE); if (theSearch.rwiProcess != null && theSearch.rwiProcess.isAlive()) try {theSearch.rwiProcess.join();} catch (final InterruptedException e) {} if (theSearch.local_rwi_available.get() == 0) { diff --git a/htroot/yacy/search.java b/htroot/yacy/search.java index 46bfef3a4..80782b527 100644 --- a/htroot/yacy/search.java +++ b/htroot/yacy/search.java @@ -255,6 +255,10 @@ public final class search { 0.0d, new String[0] ); + theQuery.setStandardFacetsMaxCount(sb.getConfigInt(SwitchboardConstants.SEARCH_NAVIGATION_MAXCOUNT, + QueryParams.FACETS_STANDARD_MAXCOUNT_DEFAULT)); + theQuery.setDateFacetMaxCount(sb.getConfigInt(SwitchboardConstants.SEARCH_NAVIGATION_DATES_MAXCOUNT, + QueryParams.FACETS_DATE_MAXCOUNT_DEFAULT)); Network.log.info("INIT HASH SEARCH (abstracts only): " + QueryParams.anonymizedQueryHashes(theQuery.getQueryGoal().getIncludeHashes()) + " - " + theQuery.itemsPerPage() + " links"); final long timer = System.currentTimeMillis(); diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java index 1b8bc0c94..cac46a7b2 100644 --- a/htroot/yacysearch.java +++ b/htroot/yacysearch.java @@ -653,6 +653,10 @@ public class yacysearch { header.get(HeaderFramework.USER_AGENT, ""), lat, lon, rad, sb.getConfigArray("search.navigation", "")); + theQuery.setStandardFacetsMaxCount(sb.getConfigInt(SwitchboardConstants.SEARCH_NAVIGATION_MAXCOUNT, + QueryParams.FACETS_STANDARD_MAXCOUNT_DEFAULT)); + theQuery.setDateFacetMaxCount(sb.getConfigInt(SwitchboardConstants.SEARCH_NAVIGATION_DATES_MAXCOUNT, + QueryParams.FACETS_DATE_MAXCOUNT_DEFAULT)); EventTracker.delete(EventTracker.EClass.SEARCH); EventTracker.update(EventTracker.EClass.SEARCH, new ProfilingGraph.EventSearch( theQuery.id(true), diff --git a/htroot/yacysearchtrailer.java b/htroot/yacysearchtrailer.java index 068a13be0..b1f5091b0 100644 --- a/htroot/yacysearchtrailer.java +++ b/htroot/yacysearchtrailer.java @@ -110,7 +110,7 @@ public class yacysearchtrailer { navigatorIterator = languageNavigator.keys(false); int i = 0, pos = 0, neg = 0; String nav, rawNav; - while (i < QueryParams.FACETS_STANDARD_MAXCOUNT && navigatorIterator.hasNext()) { + while (i < theSearch.getQuery().getStandardFacetsMaxCount() && navigatorIterator.hasNext()) { name = navigatorIterator.next(); count = languageNavigator.get(name); if (count == 0) break; @@ -202,7 +202,7 @@ public class yacysearchtrailer { if (oldProtocolModifier != null && oldProtocolModifier.length() > 0) {theSearch.query.modifier.remove("/" + oldProtocolModifier); theSearch.query.modifier.remove(oldProtocolModifier);} theSearch.query.modifier.protocol = ""; theSearch.query.getQueryGoal().query_original = oldQuery.replaceAll(" /https", "").replaceAll(" /http", "").replaceAll(" /ftp", "").replaceAll(" /smb", "").replaceAll(" /file", ""); - while (i < QueryParams.FACETS_STANDARD_MAXCOUNT && navigatorIterator.hasNext()) { + while (i < theSearch.getQuery().getStandardFacetsMaxCount() && navigatorIterator.hasNext()) { name = navigatorIterator.next().trim(); count = theSearch.protocolNavigator.get(name); if (count == 0) break; @@ -253,7 +253,7 @@ public class yacysearchtrailer { if (fromconstraint == null) fromconstraint = new Date(System.currentTimeMillis() - AbstractFormatter.normalyearMillis); Date toconstraint = theSearch.getQuery().modifier.to == null ? null : DateDetection.parseLine(theSearch.getQuery().modifier.to, theSearch.getQuery().timezoneOffset); if (toconstraint == null) toconstraint = new Date(System.currentTimeMillis() + AbstractFormatter.normalyearMillis); - while (i < QueryParams.FACETS_DATE_MAXCOUNT && navigatorIterator.hasNext()) { + while (i < theSearch.getQuery().getDateFacetMaxCount() && navigatorIterator.hasNext()) { name = navigatorIterator.next().trim(); if (name.length() < 10) continue; count = theSearch.dateNavigator.get(name); @@ -266,7 +266,7 @@ public class yacysearchtrailer { if (fromconstraint != null && dd.before(fromconstraint)) continue; if (toconstraint != null && dd.after(toconstraint)) break; if (dx > 0) { - while (d - dx > AbstractFormatter.dayMillis) { + while (d - dx > AbstractFormatter.dayMillis && i < theSearch.getQuery().getDateFacetMaxCount()) { dx += AbstractFormatter.dayMillis; String sn = new Date(dx).toInstant().toString().substring(0, 10); prop.put("nav-dates_element_" + i + "_on", 0); @@ -359,7 +359,7 @@ public class yacysearchtrailer { navigatorIterator = navi.keys(false); int i = 0, pos = 0, neg = 0; String nav, rawNav; - while (i < QueryParams.FACETS_STANDARD_MAXCOUNT && navigatorIterator.hasNext()) { + while (i < theSearch.getQuery().getStandardFacetsMaxCount() && navigatorIterator.hasNext()) { name = navigatorIterator.next(); count = navi.get(name); if (count == 0) { |
