@@ -454,18 +454,18 @@ static int parseSortby(PLN_ArrangeStep *arng, ArgsCursor *ac, QueryError *status
454454 return REDISMODULE_ERR ;
455455}
456456
457- static int parseQueryLegacyArgs (ArgsCursor * ac , RSSearchOptions * options , QueryError * status ) {
457+ static int parseQueryLegacyArgs (ArgsCursor * ac , RSSearchOptions * options , bool * hasEmptyFilterValue , QueryError * status ) {
458458 if (AC_AdvanceIfMatch (ac , "FILTER" )) {
459459 // Numeric filter
460460 NumericFilter * * curpp = array_ensure_tail (& options -> legacy .filters , NumericFilter * );
461- * curpp = NumericFilter_LegacyParse (ac , status );
461+ * curpp = NumericFilter_LegacyParse (ac , hasEmptyFilterValue , status );
462462 if (!* curpp ) {
463463 return ARG_ERROR ;
464464 }
465465 } else if (AC_AdvanceIfMatch (ac , "GEOFILTER" )) {
466466 GeoFilter * cur_gf = rm_new (* cur_gf );
467467 array_ensure_append_1 (options -> legacy .geo_filters , cur_gf );
468- if (GeoFilter_LegacyParse (cur_gf , ac , status ) != REDISMODULE_OK ) {
468+ if (GeoFilter_LegacyParse (cur_gf , ac , hasEmptyFilterValue , status ) != REDISMODULE_OK ) {
469469 return ARG_ERROR ;
470470 }
471471 } else {
@@ -509,6 +509,7 @@ static int parseQueryArgs(ArgsCursor *ac, AREQ *req, RSSearchOptions *searchOpts
509509
510510 req -> reqflags |= QEXEC_FORMAT_DEFAULT ;
511511 bool optimization_specified = false;
512+ bool hasEmptyFilterValue = false;
512513 while (!AC_IsAtEnd (ac )) {
513514 ACArgSpec * errSpec = NULL ;
514515 int rv = AC_ParseArgSpec (ac , querySpecs , & errSpec );
@@ -546,7 +547,7 @@ static int parseQueryArgs(ArgsCursor *ac, AREQ *req, RSSearchOptions *searchOpts
546547 req -> reqflags |= QEXEC_F_SEND_HIGHLIGHT ;
547548
548549 } else if ((req -> reqflags & QEXEC_F_IS_SEARCH ) &&
549- ((rv = parseQueryLegacyArgs (ac , searchOpts , status )) != ARG_UNKNOWN )) {
550+ ((rv = parseQueryLegacyArgs (ac , searchOpts , & hasEmptyFilterValue , status )) != ARG_UNKNOWN )) {
550551 if (rv == ARG_ERROR ) {
551552 return REDISMODULE_ERR ;
552553 }
@@ -568,6 +569,12 @@ static int parseQueryArgs(ArgsCursor *ac, AREQ *req, RSSearchOptions *searchOpts
568569 }
569570 }
570571
572+ // In dialect 2, we require a non empty numeric filter
573+ if (req -> reqConfig .dialectVersion >= 2 && hasEmptyFilterValue ){
574+ QERR_MKBADARGS_FMT (status , "Numeric/Geo filter value/s cannot be empty" );
575+ return REDISMODULE_ERR ;
576+ }
577+
571578 if (!optimization_specified && req -> reqConfig .dialectVersion >= 4 ) {
572579 // If optimize was not enabled/disabled explicitly, enable it by default starting with dialect 4
573580 req -> reqflags |= QEXEC_OPTIMIZE ;
@@ -1126,15 +1133,17 @@ int AREQ_ApplyContext(AREQ *req, RedisSearchCtx *sctx, QueryError *status) {
11261133 SetSearchCtx (sctx , req );
11271134 QueryAST * ast = & req -> ast ;
11281135
1129- int rv = QAST_Parse (ast , sctx , opts , req -> query , strlen (req -> query ), req -> reqConfig .dialectVersion , status );
1136+ unsigned long dialectVersion = req -> reqConfig .dialectVersion ;
1137+
1138+ int rv = QAST_Parse (ast , sctx , opts , req -> query , strlen (req -> query ), dialectVersion , status );
11301139 if (rv != REDISMODULE_OK ) {
11311140 return REDISMODULE_ERR ;
11321141 }
11331142
1134- if (QAST_EvalParams (ast , opts , status ) != REDISMODULE_OK ) {
1143+ if (QAST_EvalParams (ast , opts , dialectVersion , status ) != REDISMODULE_OK ) {
11351144 return REDISMODULE_ERR ;
11361145 }
1137- if (applyGlobalFilters (opts , ast , sctx , req -> reqConfig . dialectVersion , status ) != REDISMODULE_OK ) {
1146+ if (applyGlobalFilters (opts , ast , sctx , dialectVersion , status ) != REDISMODULE_OK ) {
11381147 return REDISMODULE_ERR ;
11391148 }
11401149
0 commit comments