@@ -326,7 +326,7 @@ public boolean partitionKeyRestrictionsAreSatisfiedBy(DecoratedKey key, Abstract
326326 ByteBuffer value = keyValidator instanceof CompositeType
327327 ? ((CompositeType ) keyValidator ).split (key .getKey ())[e .column .position ()]
328328 : key .getKey ();
329- if (!e .operator ().isSatisfiedBy (e .column .type , value , e .value , e .analyzer ()))
329+ if (!e .operator ().isSatisfiedBy (e .column .type , value , e .value , e .indexAnalyzer (), e . queryAnalyzer ()))
330330 return false ;
331331 }
332332 return true ;
@@ -343,7 +343,7 @@ public boolean clusteringKeyRestrictionsAreSatisfiedBy(Clustering<?> clustering)
343343 if (!e .column .isClusteringColumn ())
344344 continue ;
345345
346- if (!e .operator ().isSatisfiedBy (e .column .type , clustering .bufferAt (e .column .position ()), e .value , e .analyzer ()))
346+ if (!e .operator ().isSatisfiedBy (e .column .type , clustering .bufferAt (e .column .position ()), e .value , e .indexAnalyzer (), e . queryAnalyzer ()))
347347 return false ;
348348 }
349349 return true ;
@@ -577,7 +577,7 @@ else if (builder.current.children.size() == 1 && builder.current.expressions.isE
577577 public SimpleExpression add (ColumnMetadata def , Operator op , ByteBuffer value )
578578 {
579579 assert op != Operator .ANN : "ANN expressions should be added with the addANNExpression method" ;
580- SimpleExpression expression = new SimpleExpression (def , op , value , analyzer (def , op ), null );
580+ SimpleExpression expression = new SimpleExpression (def , op , value , indexAnalyzer ( def , op ), queryAnalyzer (def , op ), null );
581581 add (expression );
582582 return expression ;
583583 }
@@ -591,18 +591,24 @@ public SimpleExpression add(ColumnMetadata def, Operator op, ByteBuffer value)
591591 */
592592 public void addANNExpression (ColumnMetadata def , ByteBuffer value , ANNOptions annOptions )
593593 {
594- add (new SimpleExpression (def , Operator .ANN , value , null , annOptions ));
594+ add (new SimpleExpression (def , Operator .ANN , value , null , null , annOptions ));
595595 }
596596
597597 public void addMapComparison (ColumnMetadata def , ByteBuffer key , Operator op , ByteBuffer value )
598598 {
599- add (new MapComparisonExpression (def , key , op , value , analyzer (def , op )));
599+ add (new MapComparisonExpression (def , key , op , value , indexAnalyzer ( def , op ), queryAnalyzer (def , op )));
600600 }
601601
602602 @ Nullable
603- private Index .Analyzer analyzer (ColumnMetadata def , Operator op )
603+ private Index .Analyzer indexAnalyzer (ColumnMetadata def , Operator op )
604604 {
605- return indexRegistry == null ? null : indexRegistry .getAnalyzerFor (def , op ).orElse (null );
605+ return indexRegistry == null ? null : indexRegistry .getIndexAnalyzerFor (def , op ).orElse (null );
606+ }
607+
608+ @ Nullable
609+ private Index .Analyzer queryAnalyzer (ColumnMetadata def , Operator op )
610+ {
611+ return indexRegistry == null ? null : indexRegistry .getQueryAnalyzerFor (def , op ).orElse (null );
606612 }
607613
608614 public void addGeoDistanceExpression (ColumnMetadata def , ByteBuffer point , Operator op , ByteBuffer distance )
@@ -981,7 +987,13 @@ public Operator operator()
981987 }
982988
983989 @ Nullable
984- public Index .Analyzer analyzer ()
990+ public Index .Analyzer indexAnalyzer ()
991+ {
992+ return null ;
993+ }
994+
995+ @ Nullable
996+ public Index .Analyzer queryAnalyzer ()
985997 {
986998 return null ;
987999 }
@@ -1176,7 +1188,9 @@ public Expression deserialize(DataInputPlus in, int version, TableMetadata metad
11761188 ByteBuffer name = ByteBufferUtil .readWithShortLength (in );
11771189 Operator operator = Operator .readFrom (in );
11781190 ColumnMetadata column = metadata .getColumn (name );
1179- Index .Analyzer analyzer = IndexRegistry .obtain (metadata ).getAnalyzerFor (column , operator ).orElse (null );
1191+ IndexRegistry indexRegistry = IndexRegistry .obtain (metadata );
1192+ Index .Analyzer indexAnalyzer = indexRegistry .getIndexAnalyzerFor (column , operator ).orElse (null );
1193+ Index .Analyzer queryAnalyzer = indexRegistry .getQueryAnalyzerFor (column , operator ).orElse (null );
11801194
11811195 // Compact storage tables, when used with thrift, used to allow falling through this withouot throwing an
11821196 // exception. However, since thrift was removed in 4.0, this behaviour was not restored in CASSANDRA-16217
@@ -1188,11 +1202,11 @@ public Expression deserialize(DataInputPlus in, int version, TableMetadata metad
11881202 case SIMPLE :
11891203 ByteBuffer value = ByteBufferUtil .readWithShortLength (in );
11901204 ANNOptions annOptions = operator == Operator .ANN ? ANNOptions .serializer .deserialize (in , version ) : null ;
1191- return new SimpleExpression (column , operator , value , analyzer , annOptions );
1205+ return new SimpleExpression (column , operator , value , indexAnalyzer , queryAnalyzer , annOptions );
11921206 case MAP_COMPARISON :
11931207 ByteBuffer key = ByteBufferUtil .readWithShortLength (in );
11941208 ByteBuffer val = ByteBufferUtil .readWithShortLength (in );
1195- return new MapComparisonExpression (column , key , operator , val , analyzer );
1209+ return new MapComparisonExpression (column , key , operator , val , indexAnalyzer , queryAnalyzer );
11961210 case VECTOR_RADIUS :
11971211 Operator boundaryOperator = Operator .readFrom (in );
11981212 ByteBuffer distance = ByteBufferUtil .readWithShortLength (in );
@@ -1249,26 +1263,40 @@ public long serializedSize(Expression expression, int version)
12491263 public abstract static class AnalyzableExpression extends Expression
12501264 {
12511265 @ Nullable
1252- protected final Index .Analyzer analyzer ;
1266+ protected final Index .Analyzer indexAnalyzer ;
1267+
1268+ @ Nullable
1269+ protected final Index .Analyzer queryAnalyzer ;
12531270
1254- public AnalyzableExpression (ColumnMetadata column , Operator operator , ByteBuffer value , @ Nullable Index .Analyzer analyzer )
1271+ public AnalyzableExpression (ColumnMetadata column ,
1272+ Operator operator ,
1273+ ByteBuffer value ,
1274+ @ Nullable Index .Analyzer indexAnalyzer ,
1275+ @ Nullable Index .Analyzer queryAnalyzer )
12551276 {
12561277 super (column , operator , value );
1257- this .analyzer = analyzer ;
1278+ this .indexAnalyzer = indexAnalyzer ;
1279+ this .queryAnalyzer = queryAnalyzer ;
1280+ }
1281+
1282+ @ Nullable
1283+ public final Index .Analyzer indexAnalyzer ()
1284+ {
1285+ return indexAnalyzer ;
12581286 }
12591287
12601288 @ Nullable
1261- public final Index .Analyzer analyzer ()
1289+ public final Index .Analyzer queryAnalyzer ()
12621290 {
1263- return analyzer ;
1291+ return queryAnalyzer ;
12641292 }
12651293
12661294 @ Override
12671295 public int numFilteredValues ()
12681296 {
1269- return analyzer == null
1297+ return indexAnalyzer == null
12701298 ? super .numFilteredValues ()
1271- : analyzer ().analyze (value ).size ();
1299+ : indexAnalyzer ().analyze (value ).size ();
12721300 }
12731301 }
12741302
@@ -1283,10 +1311,11 @@ public static class SimpleExpression extends AnalyzableExpression
12831311 public SimpleExpression (ColumnMetadata column ,
12841312 Operator operator ,
12851313 ByteBuffer value ,
1286- @ Nullable Index .Analyzer analyzer ,
1314+ @ Nullable Index .Analyzer indexAnalyzer ,
1315+ @ Nullable Index .Analyzer queryAnalyzer ,
12871316 @ Nullable ANNOptions annOptions )
12881317 {
1289- super (column , operator , value , analyzer );
1318+ super (column , operator , value , indexAnalyzer , queryAnalyzer );
12901319 this .annOptions = annOptions ;
12911320 }
12921321
@@ -1324,13 +1353,13 @@ public boolean isSatisfiedBy(TableMetadata metadata, DecoratedKey partitionKey,
13241353 return false ;
13251354
13261355 ByteBuffer counterValue = LongType .instance .decompose (CounterContext .instance ().total (foundValue , ByteBufferAccessor .instance ));
1327- return operator .isSatisfiedBy (LongType .instance , counterValue , value , analyzer );
1356+ return operator .isSatisfiedBy (LongType .instance , counterValue , value , indexAnalyzer , queryAnalyzer );
13281357 }
13291358 else
13301359 {
13311360 // Note that CQL expression are always of the form 'x < 4', i.e. the tested value is on the left.
13321361 ByteBuffer foundValue = getValue (metadata , partitionKey , row , nowInSec );
1333- return foundValue != null && operator .isSatisfiedBy (column .type , foundValue , value , analyzer );
1362+ return foundValue != null && operator .isSatisfiedBy (column .type , foundValue , value , indexAnalyzer , queryAnalyzer );
13341363 }
13351364 }
13361365 case NEQ :
@@ -1344,7 +1373,7 @@ public boolean isSatisfiedBy(TableMetadata metadata, DecoratedKey partitionKey,
13441373 assert !column .isComplex () : "Only CONTAINS and CONTAINS_KEY are supported for collection types" ;
13451374 ByteBuffer foundValue = getValue (metadata , partitionKey , row , nowInSec );
13461375 // Note that CQL expression are always of the form 'x < 4', i.e. the tested value is on the left.
1347- return foundValue != null && operator .isSatisfiedBy (column .type , foundValue , value , analyzer );
1376+ return foundValue != null && operator .isSatisfiedBy (column .type , foundValue , value , indexAnalyzer , queryAnalyzer );
13481377 }
13491378 case CONTAINS :
13501379 return contains (metadata , partitionKey , row , nowInSec );
@@ -1475,9 +1504,10 @@ public MapComparisonExpression(ColumnMetadata column,
14751504 ByteBuffer key ,
14761505 Operator operator ,
14771506 ByteBuffer value ,
1478- @ Nullable Index .Analyzer analyzer )
1507+ @ Nullable Index .Analyzer indexAnalyzer ,
1508+ @ Nullable Index .Analyzer queryAnalyzer )
14791509 {
1480- super (column , operator , value , analyzer );
1510+ super (column , operator , value , indexAnalyzer , queryAnalyzer );
14811511 assert column .type instanceof MapType && (operator == Operator .EQ || operator == Operator .NEQ || operator .isSlice ());
14821512 this .key = key ;
14831513 }
0 commit comments