diff options
| author | Michael Peter Christen <mc@yacy.net> | 2026-01-03 03:37:32 +0100 |
|---|---|---|
| committer | Michael Peter Christen <mc@yacy.net> | 2026-01-03 03:37:32 +0100 |
| commit | 49f445d556ee98c494760e08d44b40455e392a13 (patch) | |
| tree | 55bea06fcdfa55e84551ea95b122a09f236ddab7 | |
| parent | e2d0050a1c15df8fda56edb5bc559d84149e6633 (diff) | |
Fix: avoid 0-results by using remote metadata results when available
Use the remote metadata list directly (via addNodes) after
storing/committing remote search results. This bypasses the flaky
RWI→metadata lookup that can drop all results and yield a ZERO COUNT
even when peers return references.
| -rw-r--r-- | source/net/yacy/peers/Protocol.java | 30 | ||||
| -rw-r--r-- | source/net/yacy/search/query/SearchEvent.java | 3 |
2 files changed, 21 insertions, 12 deletions
diff --git a/source/net/yacy/peers/Protocol.java b/source/net/yacy/peers/Protocol.java index 7696171fb..569dfccc9 100644 --- a/source/net/yacy/peers/Protocol.java +++ b/source/net/yacy/peers/Protocol.java @@ -789,18 +789,24 @@ public final class Protocol { }
WriteMetadataNodeToLocalIndexThread writerToLocalIndex = new WriteMetadataNodeToLocalIndexThread(event.query.getSegment(), storeDocs);
writerToLocalIndex.start();
- try {
- writerToLocalIndex.join();
- } catch(InterruptedException e) {
- /*
- * Current thread interruption might happen while waiting
- * for writeToLocalIndexThread.
- */
- writerToLocalIndex.stopWriting();
- throw new InterruptedException("remoteProcess stopped!");
- }
- event.addRWIs(container.get(0), false, target.getName() + "/" + target.hash, result.totalCount, time);
- } else {
+ try { + writerToLocalIndex.join(); + } catch(InterruptedException e) { + /* + * Current thread interruption might happen while waiting + * for writeToLocalIndexThread. + */ + writerToLocalIndex.stopWriting(); + throw new InterruptedException("remoteProcess stopped!"); + } + /* Ensure freshly stored metadata is visible to queries before adding results. */ + event.query.getSegment().fulltext().commit(true); + if (storeDocs != null && !storeDocs.isEmpty()) { + event.addNodes(storeDocs, null, snip, false, target.getName() + "/" + target.hash, result.totalCount, true); + } else { + event.addRWIs(container.get(0), false, target.getName() + "/" + target.hash, result.totalCount, time); + } + } else { // feed results as nodes (SolrQuery results) which carry metadata,
// to prevent a call to getMetaData for RWI results, which would fail (if no metadata in index and no display of these results)
event.addNodes(storeDocs, null, snip, false, target.getName() + "/" + target.hash, count, true);
diff --git a/source/net/yacy/search/query/SearchEvent.java b/source/net/yacy/search/query/SearchEvent.java index ea3774897..31bf06c05 100644 --- a/source/net/yacy/search/query/SearchEvent.java +++ b/source/net/yacy/search/query/SearchEvent.java @@ -2046,6 +2046,9 @@ public final class SearchEvent implements ScoreMapUpdatesListener { // we did not demand online loading, therefore a failure does not mean that the missing snippet causes a rejection of this result // this may happen during a remote search, because snippet loading is omitted to retrieve results faster return page.makeResultEntry(this.query.getSegment(), this.peers, null); // result without snippet + } else if (!this.query.isLocal() || cacheStrategy == CacheStrategy.IFEXIST || cacheStrategy == CacheStrategy.IFFRESH) { + /* Do not drop remote or "use cache if available" results when snippet fetching fails. */ + return page.makeResultEntry(this.query.getSegment(), this.peers, null); // result without snippet } else { // problems with snippet fetch if (this.snippetFetchWords.contains(Segment.catchallString)) { |
