Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
possible fix for search-0-results bug from https://github.com/yacy/yacy_search_server/issues/499
Michael Peter Christen2819742bdb05
diff --git a/defaults/yacy.init b/defaults/yacy.initindex 9efa1ef42..5f9087afa 100644--- a/defaults/yacy.init+++ b/defaults/yacy.init@@ -1013,7 +1013,7 @@ search.verify.delete = true# If enabled, the results are sorted in the browser using Javascript.# This usually improves ranking accuracy, but doesn't work well for users# who have Javascript disabled, are using screen readers, or are on slow computers.-search.jsresort = false+search.jsresort = true# remote search detailsremotesearch.maxcount = 10diff --git a/htroot/js/yacysort.js b/htroot/js/yacysort.jsindex d3769c225..e2d9bd835 100644--- a/htroot/js/yacysort.js+++ b/htroot/js/yacysort.js@@ -327,9 +327,14 @@ var updateSidebar = function() {*/var processLatestInfo = function(latestInfo) {if (latestInfo.feedRunning) {- $.get("yacysearchlatestinfo.json", {- eventID : theEventID- }, processItem);+ $.get(+ "yacysearchitem.html",+ {+ eventID : theEventID,+ item: itemCount+ },+ processItem+ );} else {fetchingResults = false;}diff --git a/source/net/yacy/htroot/yacysearch.java b/source/net/yacy/htroot/yacysearch.javaindex ac728a4a3..fa1e452bd 100644--- a/source/net/yacy/htroot/yacysearch.java+++ b/source/net/yacy/htroot/yacysearch.java@@ -836,6 +836,18 @@ public class yacysearch {theQuery.setOffset(0); // in case that this is a new search, always start without a offsetstartRecord = 0;}+ ConcurrentLog.info(+ "LOCAL_SEARCH",+ "SEARCH EVENT: id="+ + theQuery.id(false)+ + " cached="+ + (cachedEvent != null)+ + " query="+ + theQuery.getQueryGoal().getQueryString(false)+ + " startRecord="+ + startRecord+ + " itemsPerPage="+ + theQuery.itemsPerPage());final SearchEvent theSearch =SearchEventCache.getEvent(theQuery,@@ -971,6 +983,25 @@ public class yacysearch {prop.put("num-results_globalresults_remoteIndexCount", Formatter.number(theSearch.remote_rwi_available.get() + theSearch.remote_solr_available.get(), true));prop.put("num-results_globalresults_remotePeerCount", Formatter.number(theSearch.remote_rwi_peerCount.get() + theSearch.remote_solr_peerCount.get(), true));+ if (theSearch.getResultCount() == 0 && querystring.length() > 0) {+ ConcurrentLog.info(+ "LOCAL_SEARCH",+ "ZERO RESULTS: id="+ + theQuery.id(false)+ + " query="+ + theQuery.getQueryGoal().getQueryString(false)+ + " localAvailable="+ + (theSearch.local_rwi_available.get() + theSearch.local_solr_stored.get())+ + " localStored="+ + (theSearch.local_rwi_stored.get() + theSearch.local_solr_stored.get())+ + " remoteAvailable="+ + (theSearch.remote_rwi_available.get() + theSearch.remote_solr_available.get())+ + " remoteStored="+ + (theSearch.remote_rwi_stored.get() + theSearch.remote_solr_stored.get())+ + " feedRunning="+ + (!theSearch.isFeedingFinished()));+ }+prop.put("jsResort", jsResort);prop.put("num-results_jsResort", jsResort);diff --git a/source/net/yacy/htroot/yacysearchitem.java b/source/net/yacy/htroot/yacysearchitem.javaindex 9dc1912e1..d488480f6 100644--- a/source/net/yacy/htroot/yacysearchitem.java+++ b/source/net/yacy/htroot/yacysearchitem.java@@ -168,7 +168,21 @@ public class yacysearchitem {// generate result objectfinal URIMetadataNode result = theSearch.oneResult(item, timeout);- if (result == null) return prop; // no content+ if (result == null) {+ ConcurrentLog.info(+ "yacysearchitem",+ "NO RESULT: eventID="+ + eventID+ + " item="+ + item+ + " timeout="+ + timeout+ + " resultCount="+ + theSearch.getResultCount()+ + " feedRunning="+ + (!theSearch.isFeedingFinished()));+ return prop; // no content+ }final String resultUrlstring = result.urlstring();final DigestURL resultURL = result.url();final String target = sb.getConfig(resultUrlstring.matches(target_special_pattern) ? SwitchboardConstants.SEARCH_TARGET_SPECIAL : SwitchboardConstants.SEARCH_TARGET_DEFAULT, "_self");diff --git a/source/net/yacy/htroot/yacysearchlatestinfo.java b/source/net/yacy/htroot/yacysearchlatestinfo.javaindex 5a77b0fd1..c62239155 100644--- a/source/net/yacy/htroot/yacysearchlatestinfo.java+++ b/source/net/yacy/htroot/yacysearchlatestinfo.java@@ -3,6 +3,7 @@ package net.yacy.htroot;import net.yacy.cora.protocol.RequestHeader;import net.yacy.data.UserDB;import net.yacy.http.servlets.TemplateMissingParameterException;+import net.yacy.cora.util.ConcurrentLog;import net.yacy.kelondro.util.Formatter;import net.yacy.search.Switchboard;import net.yacy.search.query.QueryParams;@@ -59,7 +60,23 @@ public class yacysearchlatestinfo {prop.put("remoteIndexCount", Formatter.number(theSearch.remote_rwi_available.get() + theSearch.remote_solr_available.get(), true));prop.put("remotePeerCount", Formatter.number(theSearch.remote_rwi_peerCount.get() + theSearch.remote_solr_peerCount.get(), true));prop.putJSON("navurlBase", QueryParams.navurlBase(RequestHeader.FileType.HTML, theSearch.query, null, false, authenticated).toString());- prop.put("feedRunning", Boolean.toString(!theSearch.isFeedingFinished()));+ final boolean feedRunning = !theSearch.isFeedingFinished();+ prop.put("feedRunning", Boolean.toString(feedRunning));++ if (theSearch.getResultCount() == 0) {+ ConcurrentLog.info(+ "yacysearchlatestinfo",+ "ZERO COUNT: eventID="+ + eventID+ + " query="+ + theSearch.query.getQueryGoal().getQueryString(false)+ + " offset="+ + offset+ + " itemsPerPage="+ + theSearch.query.itemsPerPage+ + " feedRunning="+ + feedRunning);+ }return prop;}diff --git a/source/net/yacy/search/query/SearchEventCache.java b/source/net/yacy/search/query/SearchEventCache.javaindex b8d9d4080..879236771 100644--- a/source/net/yacy/search/query/SearchEventCache.java+++ b/source/net/yacy/search/query/SearchEventCache.java@@ -141,40 +141,42 @@ public class SearchEventCache {final int remote_maxcount,final long remote_maxtime) {- if (MemoryControl.shortStatus()) cleanupEvents(true);- final String id = query.id(false);- SearchEvent event = getEvent(id);- if (Switchboard.getSwitchboard() != null && !Switchboard.getSwitchboard().crawlQueues.noticeURL.isEmpty() && event != null && System.currentTimeMillis() - event.getEventTime() > 60000) {- // if a local crawl is ongoing, don't use the result from the cache to use possibly more results that come from the current crawl- // to prevent that this happens during a person switches between the different result pages, a re-search happens no more than- // once a minute- synchronized (lastEvents) {+ if (MemoryControl.shortStatus()) cleanupEvents(true);+ final String id = query.id(false);+ SearchEvent event = getEvent(id);+ if (event != null && query.isLocal()) {+ synchronized (lastEvents) {+ lastEvents.remove(id);+ }+ cacheDelete++;+ event = null;+ }+ if (Switchboard.getSwitchboard() != null && !Switchboard.getSwitchboard().crawlQueues.noticeURL.isEmpty() && event != null && System.currentTimeMillis() - event.getEventTime() > 60000) {+ // if a local crawl is ongoing, don't use the result from the cache to use possibly more results that come from the current crawl+ // to prevent that this happens during a person switches between the different result pages, a re-search happens no more than+ // once a minute+ synchronized (lastEvents) {lastEvents.remove(id);}- cacheDelete++;- event = null;- } else {- if (event != null) {- if(query.isLocal()) {- /* Searching the local index only : we do not reuse the cached event each time the page size or offset changes.- * This allow to request last result pages of large result sets (larger than SearchEvent.max_results_node)- * without the need to retrieve all the beginning pages */- if(event.query.offset != query.offset || event.query.itemsPerPage != query.itemsPerPage) {- synchronized (lastEvents) {- lastEvents.remove(id);- }- cacheDelete++;- event = null;- }- } else {- //re-new the event time for this event, so it is not deleted next time too early- event.resetEventTime();- // replace the current result offset- event.query.offset = query.offset;- event.query.itemsPerPage = query.itemsPerPage;- }- }- }+ cacheDelete++;+ event = null;+ } else {+ if (event != null) {+ if (!query.isLocal() && event.getResultCount() == 0 && event.isFeedingFinished()) {+ synchronized (lastEvents) {+ lastEvents.remove(id);+ }+ cacheDelete++;+ event = null;+ } else if (event != null) {+ // re-new the event time for this event, so it is not deleted next time too early+ event.resetEventTime();+ // replace the current result offset+ event.query.offset = query.offset;+ event.query.itemsPerPage = query.itemsPerPage;+ }+ }+ }if (event == null) {// check if there are too many other searches alive nowsynchronized (lastEvents) {