Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

changed search process for images: no more media snippet load process, show only links from index which had been on the text search page before. This creates a superfast search process for images!

Michael Peter Christena3badd320517
diff --git a/htroot/ViewFile.java b/htroot/ViewFile.java
index 601a60506..a77431a47 100644
--- a/htroot/ViewFile.java
+++ b/htroot/ViewFile.java
@@ -160,7 +160,7 @@ public class ViewFile {
}
// loading the resource content as byte array
- prop.put("error_incache", Cache.has(url) ? 1 : 0);
+ prop.put("error_incache", Cache.has(url.hash()) ? 1 : 0);
Response response = null;
try {
diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.java
index f57ab8be5..cc3fb9853 100644
--- a/htroot/yacysearchitem.java
+++ b/htroot/yacysearchitem.java
@@ -215,29 +215,30 @@ public class yacysearchitem {
// image search; shows thumbnails
prop.put("content", theQuery.contentdom.getCode() + 1); // switch on specific content
- final MediaSnippet ms = theSearch.result().oneImage(item);
+ //final MediaSnippet ms = theSearch.result().oneImage(item);
+ final ResultEntry ms = theSearch.oneResult(item, theQuery.isLocal() ? 1000 : 5000);
if (ms == null) {
prop.put("content_item", "0");
} else {
- final String resultUrlstring = ms.href.toNormalform(true, false);
+ final String resultUrlstring = ms.url().toNormalform(true, false);
final String target = sb.getConfig(resultUrlstring.matches(target_special_pattern) ? SwitchboardConstants.SEARCH_TARGET_SPECIAL : SwitchboardConstants.SEARCH_TARGET_DEFAULT, "_self");
- final String license = sb.licensedURLs.aquireLicense(ms.href);
- sb.loader.loadIfNotExistBackground(ms.href, 1024 * 1024 * 10);
+ final String license = sb.licensedURLs.aquireLicense(ms.url());
+ sb.loader.loadIfNotExistBackground(ms.url(), 1024 * 1024 * 10);
prop.putHTML("content_item_hrefCache", (auth) ? "/ViewImage.png?url=" + resultUrlstring : resultUrlstring);
prop.putHTML("content_item_href", resultUrlstring);
prop.putHTML("content_item_target", target);
prop.put("content_item_code", license);
- prop.putHTML("content_item_name", shorten(ms.name, MAX_NAME_LENGTH));
- prop.put("content_item_mimetype", ms.mime);
- prop.put("content_item_fileSize", ms.fileSize);
- prop.put("content_item_width", ms.width);
- prop.put("content_item_height", ms.height);
- prop.put("content_item_attr", (ms.attr.equals("-1 x -1")) ? "" : "(" + ms.attr + ")"); // attributes, here: original size of image
- prop.put("content_item_urlhash", ASCII.String(ms.source.hash()));
- prop.put("content_item_source", ms.source.toNormalform(true, false));
- prop.putXML("content_item_source-xml", ms.source.toNormalform(true, false));
- prop.put("content_item_sourcedom", ms.source.getHost());
+ prop.putHTML("content_item_name", shorten(ms.title(), MAX_NAME_LENGTH));
+ prop.put("content_item_mimetype", "");
+ prop.put("content_item_fileSize", 0);
+ prop.put("content_item_width", 0);
+ prop.put("content_item_height", 0);
+ prop.put("content_item_attr", ""/*(ms.attr.equals("-1 x -1")) ? "" : "(" + ms.attr + ")"*/); // attributes, here: original size of image
+ prop.put("content_item_urlhash", ASCII.String(ms.url().hash()));
+ prop.put("content_item_source", ms.url().toNormalform(true, false));
+ prop.putXML("content_item_source-xml", ms.url().toNormalform(true, false));
+ prop.put("content_item_sourcedom", ms.url().getHost());
prop.put("content_item_nl", (item == theQuery.offset) ? 0 : 1);
prop.put("content_item", 1);
}
diff --git a/source/net/yacy/search/query/SnippetProcess.java b/source/net/yacy/search/query/SnippetProcess.java
index 554f0cca6..37beee409 100644
--- a/source/net/yacy/search/query/SnippetProcess.java
+++ b/source/net/yacy/search/query/SnippetProcess.java
@@ -612,27 +612,6 @@ public class SnippetProcess {
Log.logInfo("SEARCH", "sorted out url " + page.url().toNormalform(true, false) + " during search: " + reason);
return null;
}
- } else if (page.url().getContentDomain() == Classification.ContentDomain.IMAGE) {
- // attach media information
- startTime = System.currentTimeMillis();
- final List<MediaSnippet> mediaSnippets = MediaSnippet.retrieveMediaSnippets(page.url(), this.snippetFetchWordHashes, this.query.contentdom, cacheStrategy, 6000, !this.query.isLocal());
- final long snippetComputationTime = System.currentTimeMillis() - startTime;
- Log.logInfo("SEARCH", "media snippet load time for " + page.url() + ": " + snippetComputationTime);
-
- if (mediaSnippets != null && !mediaSnippets.isEmpty()) {
- // found media snippets, return entry
- return new ResultEntry(page, this.query.getSegment(), this.peers, null, mediaSnippets, dbRetrievalTime, snippetComputationTime);
- } else if (cacheStrategy.mustBeOffline()) {
- return new ResultEntry(page, this.query.getSegment(), this.peers, null, null, dbRetrievalTime, snippetComputationTime);
- } else {
- // problems with snippet fetch
- final String reason = "no media snippet";
- if (this.deleteIfSnippetFail) {
- this.workTables.failURLsRegisterMissingWord(this.query.getSegment().termIndex(), page.url(), this.query.queryHashes, reason);
- }
- Log.logInfo("SEARCH", "sorted out url " + page.url().toNormalform(true, false) + " during search: " + reason);
- return null;
- }
} else {
return new ResultEntry(page, this.query.getSegment(), this.peers, null, null, dbRetrievalTime, 0); // result without snippet
}
diff --git a/source/net/yacy/search/snippet/TextSnippet.java b/source/net/yacy/search/snippet/TextSnippet.java
index 30a80008b..6614e093a 100644
--- a/source/net/yacy/search/snippet/TextSnippet.java
+++ b/source/net/yacy/search/snippet/TextSnippet.java
@@ -266,7 +266,7 @@ public class TextSnippet implements Comparable<TextSnippet>, Comparator<TextSnip
// first try to get the snippet from metadata
String loc;
final Request request = loader.request(url, true, reindexing);
- final boolean inCache = de.anomic.crawler.Cache.has(row.url());
+ final boolean inCache = de.anomic.crawler.Cache.has(row.hash());
final boolean noCacheUsage = url.isFile() || url.isSMB() || cacheStrategy == null;
if (containsAllHashes(loc = row.dc_title(), queryhashes) ||
containsAllHashes(loc = row.dc_creator(), queryhashes) ||