diff --git a/source/net/yacy/search/schema/CollectionConfiguration.java b/source/net/yacy/search/schema/CollectionConfiguration.java index 5d39c5fb46..4e2b6076a4 100644 --- a/source/net/yacy/search/schema/CollectionConfiguration.java +++ b/source/net/yacy/search/schema/CollectionConfiguration.java @@ -913,24 +913,28 @@ public SolrVector yacy2solr( // handle image source meta data if (document.getContentDomain() == ContentDomain.IMAGE) { - // add image pixel size if known - Iterator imgit = document.getImages().values().iterator(); - List heights = new ArrayList<>(); - List widths = new ArrayList<>(); - List 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 imgit = document.getImages().values().iterator(); + List heights = new ArrayList<>(); + List widths = new ArrayList<>(); + List 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 cdaf114c7d..29f7fc73c5 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"),