Skip to content

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

Make sure for image resource url enabled index image pixel size fields are filled if at least one of the image size fields is enabled in index (images_height_val, images_width_val, images_pixel_val). Previously all fields were required to be enabled (hint: default setting is height + width enabled)

regera8234b7ea71d
diff --git a/source/net/yacy/search/schema/CollectionConfiguration.java b/source/net/yacy/search/schema/CollectionConfiguration.java
index 5d39c5fb4..4e2b6076a 100644
--- a/source/net/yacy/search/schema/CollectionConfiguration.java
+++ b/source/net/yacy/search/schema/CollectionConfiguration.java
@@ -913,24 +913,28 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri
// handle image source meta data
if (document.getContentDomain() == ContentDomain.IMAGE) {
- // add image pixel size if known
- Iterator<ImageEntry> imgit = document.getImages().values().iterator();
- List<Integer> heights = new ArrayList<>();
- List<Integer> widths = new ArrayList<>();
- List<Integer> pixels = new ArrayList<>();
- while (imgit.hasNext()) {
- ImageEntry img = imgit.next();
- int imgpixels = (img.height() < 0 || img.width() < 0) ? -1 : img.height() * img.width();
- if (imgpixels > 0 && (allAttr || (contains(CollectionSchema.images_height_val) && contains(CollectionSchema.images_width_val) && contains(CollectionSchema.images_pixel_val)))) {
- heights.add(img.height());
- widths.add(img.width());
- pixels.add(imgpixels);
+ // add image pixel sizes if enabled in index
+ // get values if as least one of the size fields is enabled in index
+ if (allAttr || (contains(CollectionSchema.images_height_val) || contains(CollectionSchema.images_width_val)) || contains(CollectionSchema.images_pixel_val)) {
+ // add image pixel size if known
+ Iterator<ImageEntry> imgit = document.getImages().values().iterator();
+ List<Integer> heights = new ArrayList<>();
+ List<Integer> widths = new ArrayList<>();
+ List<Integer> pixels = new ArrayList<>();
+ while (imgit.hasNext()) {
+ ImageEntry img = imgit.next();
+ int imgpixels = (img.height() < 0 || img.width() < 0) ? -1 : img.height() * img.width();
+ if (imgpixels > 0) {
+ heights.add(img.height());
+ widths.add(img.width());
+ pixels.add(imgpixels);
+ }
+ }
+ if (heights.size() > 0) { // add to index document
+ add(doc, CollectionSchema.images_height_val, heights); // add() checks if field is enabled in index
+ add(doc, CollectionSchema.images_width_val, widths);
+ add(doc, CollectionSchema.images_pixel_val, pixels);
}
- }
- if (heights.size() > 0) {
- add(doc, CollectionSchema.images_height_val, heights);
- add(doc, CollectionSchema.images_width_val, widths);
- add(doc, CollectionSchema.images_pixel_val, pixels);
}
if (allAttr || contains(CollectionSchema.images_text_t)) {
diff --git a/source/net/yacy/search/schema/CollectionSchema.java b/source/net/yacy/search/schema/CollectionSchema.java
index cdaf114c7..29f7fc73c 100644
--- a/source/net/yacy/search/schema/CollectionSchema.java
+++ b/source/net/yacy/search/schema/CollectionSchema.java
@@ -161,7 +161,7 @@ public enum CollectionSchema implements SchemaDeclaration {
images_alt_sxt(SolrType.string, true, true, true, false, true, "all image link alt tag"), // no need to index this; don't turn it into a txt field; use images_text_t instead
images_height_val(SolrType.num_integer, true, true, true, false, false, "size of images:height"),
images_width_val(SolrType.num_integer, true, true, true, false, false, "size of images:width"),
- images_pixel_val(SolrType.num_integer, true, true, true, false, false, "size of images as number of pixels (easier for a search restriction than with and height)"),
+ images_pixel_val(SolrType.num_integer, true, true, true, false, false, "size of images as number of pixels (easier for a search restriction than width and height)"),
images_withalt_i(SolrType.num_integer, true, true, false, false, false, "number of image links with alt tag"),
htags_i(SolrType.num_integer, true, true, false, false, false, "binary pattern for the existance of h1..h6 headlines"),
canonical_s(SolrType.string, true, true, false, false, false, "url inside the canonical link element"),