summaryrefslogtreecommitdiffstats
path: root/container-search/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'container-search/src/main')
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/query/parser/AllParser.java22
1 files changed, 21 insertions, 1 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/query/parser/AllParser.java b/container-search/src/main/java/com/yahoo/prelude/query/parser/AllParser.java
index 43bd175b348..692269a1412 100644
--- a/container-search/src/main/java/com/yahoo/prelude/query/parser/AllParser.java
+++ b/container-search/src/main/java/com/yahoo/prelude/query/parser/AllParser.java
@@ -11,6 +11,7 @@ import com.yahoo.prelude.query.OrItem;
import com.yahoo.prelude.query.PhraseItem;
import com.yahoo.prelude.query.QueryCanonicalizer;
import com.yahoo.prelude.query.RankItem;
+import com.yahoo.prelude.query.SegmentItem;
import com.yahoo.prelude.query.TrueItem;
import com.yahoo.prelude.query.WeakAndItem;
import com.yahoo.search.query.QueryTree;
@@ -98,10 +99,29 @@ public class AllParser extends SimpleParser {
return root.getRoot() instanceof NullItem ? null : root.getRoot();
}
+ private boolean foldIntoAnd(CompositeItem other) {
+ if (other instanceof AndItem) {
+ return true;
+ }
+ if (weakAnd && other instanceof SegmentItem) {
+ return true;
+ }
+ if (weakAnd && other instanceof PhraseItem phrase) {
+ return ! phrase.isExplicit();
+ }
+ return false;
+ }
+
protected CompositeItem addAnd(Item item, CompositeItem and) {
if (and == null)
and = createAnd();
- and.addItem(item);
+ if (item instanceof CompositeItem composite && foldIntoAnd(composite)) {
+ for (var subItem : composite.items()) {
+ addAnd(subItem, and);
+ }
+ } else {
+ and.addItem(item);
+ }
return and;
}