From 01b834077404d77b57d4b1c7f795c03b8f92a18a Mon Sep 17 00:00:00 2001 From: kwahlin Date: Fri, 29 Nov 2024 16:32:53 +0100 Subject: [PATCH] Fix more lost in transpilation errors --- .../main/groovy/whelk/search2/EsBoost.java | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/whelk-core/src/main/groovy/whelk/search2/EsBoost.java b/whelk-core/src/main/groovy/whelk/search2/EsBoost.java index 55ada5d624..f5baf2e316 100644 --- a/whelk-core/src/main/groovy/whelk/search2/EsBoost.java +++ b/whelk-core/src/main/groovy/whelk/search2/EsBoost.java @@ -86,8 +86,9 @@ private List computeBoostFields(List types) { boostFields = CONCEPT_BOOST.stream() .map(s -> s.split("\\^")) .collect(Collectors.toMap(parts -> parts[0], parts -> Integer.parseInt(parts[1]))); - - computeBoostFieldsFromLenses(otherTypes).forEach(boostFields::putIfAbsent); + if (!otherTypes.isEmpty()) { + computeBoostFieldsFromLenses(otherTypes).forEach(boostFields::putIfAbsent); + } } return boostFields.entrySet() @@ -326,18 +327,21 @@ private Map computeCardPropertyBoosts(String prop) { Map dfn = jsonLd.vocabIndex.get(prop); // Follow the object property range to append chip properties to the boosted path. - if (dfn != null && "ObjectProperty".equals(dfn.get(TYPE_KEY))) { - Optional rangeKey = Optional.ofNullable(dfn.get(RANGE)) - .map(r -> r instanceof List ? ((List) r).getFirst() : r) - .map(Map.class::cast) - .map(r -> (String) r.get(ID_KEY)) - .map(jsonLd::toTermKey); - - if (rangeKey.isPresent() && jsonLd.isSubClassOf(rangeKey.get(), "QualifiedRole")) { - var rangeChipLens = chipLenses.getLensForType(rangeKey.get()); - collectBoostFields(rangeChipLens, CARD_BOOST).forEach((k, v) -> boostFields.put(prop + "." + k, v)); - } else { + if (dfn != null) { + if ("ObjectProperty".equals(dfn.get(TYPE_KEY))) { + Optional rangeKey = Optional.ofNullable(dfn.get(RANGE)) + .map(r -> r instanceof List ? ((List) r).getFirst() : r) + .map(Map.class::cast) + .map(r -> (String) r.get(ID_KEY)) + .map(jsonLd::toTermKey); + if (rangeKey.isPresent() && jsonLd.isSubClassOf(rangeKey.get(), "QualifiedRole")) { + var rangeChipLens = chipLenses.getLensForType(rangeKey.get()); + collectBoostFields(rangeChipLens, CARD_BOOST).forEach((k, v) -> boostFields.put(prop + "." + k, v)); + return boostFields; + } boostFields.put(prop + "." + SEARCH_KEY, CARD_BOOST); + } else { + boostFields.put(prop, CARD_BOOST); } } else if (jsonLd.isLangContainer(jsonLd.context.get(prop))) { boostFields.put(prop + "." + jsonLd.locales.getFirst(), CARD_BOOST);