diff --git a/src/java/org/apache/cassandra/index/sai/plan/Operation.java b/src/java/org/apache/cassandra/index/sai/plan/Operation.java index 111c014946c8..71cd781def91 100644 --- a/src/java/org/apache/cassandra/index/sai/plan/Operation.java +++ b/src/java/org/apache/cassandra/index/sai/plan/Operation.java @@ -99,7 +99,32 @@ protected static ListMultimap analyzeGroup(QueryCont // if there is no EQ operations and NOT_EQ is met or a single NOT_EQ expression present, // in such case we know exactly that there would be no more EQ/RANGE expressions for given column // since NOT_EQ has the lowest priority. - boolean isMultiExpression = false; + boolean isMultiExpression = columnIsMultiExpression.getOrDefault(e.column(), Boolean.FALSE); + switch (e.operator()) + { + // case BM25: leave it at the default of `false` + case EQ: + // EQ operator will always be a multiple expression because it is being used by map entries + isMultiExpression = indexContext.isNonFrozenCollection(); + + // EQ wil behave like ANALYZER_MATCHES for analyzed columns if the analyzer supports EQ queries + isMultiExpression |= indexContext.isAnalyzed() && analyzerFactory.supportsEquals(); + break; + case CONTAINS: + case CONTAINS_KEY: + case NOT_CONTAINS: + case NOT_CONTAINS_KEY: + case LIKE_PREFIX: + case LIKE_MATCHES: + case ANALYZER_MATCHES: + isMultiExpression = true; + break; + case NEQ: + // NEQ operator will always be a multiple expression if it is the only operator + // (e.g. multiple NEQ expressions) + isMultiExpression = isMultiExpression || perColumn.isEmpty(); + break; + } columnIsMultiExpression.put(e.column(), isMultiExpression); if (isMultiExpression)