summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Peter Christen <mc@yacy.net>2026-01-02 20:25:04 +0100
committerMichael Peter Christen <mc@yacy.net>2026-01-02 20:25:04 +0100
commit2819742bdb053feb7057661748cc7af7dd725ff7 (patch)
treec7306ee2c09d480a98676df3d41d26186b127050
parent3ecb0b459ee8500aa721b4ee8804bbde6f5c9dc3 (diff)
possible fix for search-0-results bug from
https://github.com/yacy/yacy_search_server/issues/499
-rw-r--r--defaults/yacy.init2
-rw-r--r--htroot/js/yacysort.js11
-rw-r--r--source/net/yacy/htroot/yacysearch.java31
-rw-r--r--source/net/yacy/htroot/yacysearchitem.java16
-rw-r--r--source/net/yacy/htroot/yacysearchlatestinfo.java19
-rw-r--r--source/net/yacy/search/query/SearchEventCache.java66
6 files changed, 107 insertions, 38 deletions
diff --git a/defaults/yacy.init b/defaults/yacy.init
index 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 details
remotesearch.maxcount = 10
diff --git a/htroot/js/yacysort.js b/htroot/js/yacysort.js
index 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.java
index 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 offset
startRecord = 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.java
index 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 object
final 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.java
index 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.java
index 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 now
synchronized (lastEvents) {