Skip to content

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

Prevent search result failure on incomplete images information.

lucciomanb23a56306524
diff --git a/htroot/yacysearchitem.java b/htroot/yacysearchitem.java
index 0baf4ed34..67a299e1d 100644
--- a/htroot/yacysearchitem.java
+++ b/htroot/yacysearchitem.java
@@ -209,7 +209,12 @@ public class yacysearchitem {
}
} else {
prop.put("content_image", 1);
- prop.putXML("content_image_url", result.imageURL());
+ try {
+ prop.putXML("content_image_url", result.imageURL());
+ } catch(UnsupportedOperationException e) {
+ /* May occur when the document embedded images information is incomplete to retrieve at least an valid image url*/
+ prop.put("content_image", 0);
+ }
}
prop.put("content_urlhash", urlhash);
diff --git a/source/net/yacy/kelondro/data/meta/URIMetadataNode.java b/source/net/yacy/kelondro/data/meta/URIMetadataNode.java
index 2adf4fdc8..9590c5827 100644
--- a/source/net/yacy/kelondro/data/meta/URIMetadataNode.java
+++ b/source/net/yacy/kelondro/data/meta/URIMetadataNode.java
@@ -453,9 +453,10 @@ public class URIMetadataNode extends SolrDocument /* implements Comparable<URIMe
/**
* in case that images are embedded in the document, get one image which can be used as thumbnail
- * @return
+ * @return the first embedded image url
+ * @throws UnsupportedOperationException when there is no image URL referenced on this document
*/
- public String imageURL() {
+ public String imageURL() throws UnsupportedOperationException {
if (limage() == 0) throw new UnsupportedOperationException();
List<String> images_protocol = CollectionConfiguration.indexedList2protocolList(getFieldValues(CollectionSchema.images_protocol_sxt.getSolrFieldName()), limage());
List<String> images_stub = getStringList(CollectionSchema.images_urlstub_sxt);