diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2024-02-09 10:41:23 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2024-02-09 10:44:44 +0100 |
commit | 5abaceb7f7ae65aa0060c3141610aa82498a19d9 (patch) | |
tree | 0c10379d314948ffe91543c1d4c96c00da3b33a2 /container-search/src/main/java/com/yahoo/prelude/searcher | |
parent | 16a5444d2acda3baff9b21dd624c1f94018e0254 (diff) |
- Let there only be one way to wire query to the grouping hits.
Enforce that by requiring it in the constructor.
- Carry the DocumentDatabase along, not only the DocusumDefinitionSet.
Diffstat (limited to 'container-search/src/main/java/com/yahoo/prelude/searcher')
-rw-r--r-- | container-search/src/main/java/com/yahoo/prelude/searcher/JuniperSearcher.java | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/JuniperSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/JuniperSearcher.java index 927fa37cc77..3c4e8107df5 100644 --- a/container-search/src/main/java/com/yahoo/prelude/searcher/JuniperSearcher.java +++ b/container-search/src/main/java/com/yahoo/prelude/searcher/JuniperSearcher.java @@ -83,9 +83,7 @@ public class JuniperSearcher extends Searcher { List<Hit> hits = new ArrayList<>(worstCase); for (Iterator<Hit> i = result.hits().deepIterator(); i.hasNext();) { Hit hit = i.next(); - if ( ! (hit instanceof FastHit)) continue; - - FastHit fastHit = (FastHit)hit; + if ( ! (hit instanceof FastHit fastHit)) continue; if (fastHit.isFilled(summaryClass)) continue; hits.add(fastHit); @@ -99,9 +97,8 @@ public class JuniperSearcher extends Searcher { String summaryClass, IndexFacts.Session indexFacts) { while (hitsToHighlight.hasNext()) { Hit hit = hitsToHighlight.next(); - if ( ! (hit instanceof FastHit)) continue; + if ( ! (hit instanceof FastHit fastHit)) continue; - FastHit fastHit = (FastHit) hit; if (summaryClass != null && ! fastHit.isFilled(summaryClass)) continue; Object searchDefinitionField = fastHit.getField(Hit.SDDOCNAME_FIELD); @@ -125,9 +122,9 @@ public class JuniperSearcher extends Searcher { private class StringArrayConverter implements ArrayTraverser { - private Index index; - private boolean bolding; - private Value.ArrayValue convertedField = new Value.ArrayValue(); + private final Index index; + private final boolean bolding; + private final Value.ArrayValue convertedField = new Value.ArrayValue(); /** * This converts the backend binary highlighting of each item in an array of string field, @@ -189,8 +186,8 @@ public class JuniperSearcher extends Searcher { } if (newFieldParts != null) { i.remove(); - for (Iterator<FieldPart> j = newFieldParts.iterator(); j.hasNext();) { - i.add(j.next()); + for (FieldPart newFieldPart : newFieldParts) { + i.add(newFieldPart); } } } @@ -220,7 +217,7 @@ public class JuniperSearcher extends Searcher { if (insideHighlight) { newFieldParts.add(new BoldCloseFieldPart(boldCloseTag)); } else { - if (newFieldParts.size() > 0 + if (!newFieldParts.isEmpty() && newFieldParts.get(newFieldParts.size() - 1) instanceof BoldCloseFieldPart) { newFieldParts.remove(newFieldParts.size() - 1); } else { @@ -230,7 +227,7 @@ public class JuniperSearcher extends Searcher { } } - private List<FieldPart> initFieldParts(List<FieldPart> newFieldParts) { + private static List<FieldPart> initFieldParts(List<FieldPart> newFieldParts) { if (newFieldParts == null) newFieldParts = new ArrayList<>(); return newFieldParts; |