Skip to content

Commit 900c016

Browse files
committed
- Add parsing of WILDCARD_EMPTY response
- Add geo parsing of negative numbers
1 parent 9ad92ec commit 900c016

File tree

1 file changed

+36
-0
lines changed
  • redisinsight/ui/src/packages/ri-explain/src

1 file changed

+36
-0
lines changed

redisinsight/ui/src/packages/ri-explain/src/parser.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ enum TokenType {
1616
VECTOR = 'VECTOR',
1717
FUZZY = 'FUZZY',
1818
WILDCARD = 'WILDCARD',
19+
WILDCARD_EMPTY = 'WILDCARD_EMPTY', // <WILDCARD>}\n
1920
PREFIX = 'PREFIX',
2021
GEO_EXPR = 'GEO_EXPR',
2122
IDS_EXPR = 'IDS_EXPR',
@@ -190,6 +191,13 @@ class Lexer {
190191
break
191192
case '-':// TODO: This should be MINUS token
192193
t = new Token(TokenType.IDENTIFIER, this.C)
194+
let p = this.PeekChar()
195+
if (p !== null && isDigit(p)){
196+
this.ReadChar()
197+
const n = this.ReadNumber()
198+
t = new Token(TokenType.NUMBER, '-' + n)
199+
return t
200+
}
193201
break
194202
case ',':
195203
t = new Token(TokenType.COMMA, this.C)
@@ -557,6 +565,8 @@ class Parser {
557565
Exprs.push(this.parseLexrangeExpr())
558566
} else if (this.CurrentToken.T === TokenType.NUMBER) {
559567
Exprs.push(new Expr(this.CurrentToken.Data.toString(), EntityType.NUMBER))
568+
} else if (this.CurrentToken.T === TokenType.LESS) {
569+
Exprs.push(this.parseWildcardEmpty())
560570
}
561571

562572
this.nextToken()
@@ -630,6 +640,30 @@ class Parser {
630640
return new Expr(ids.join(','), EntityType.IDS)
631641
}
632642

643+
// This is a special result.
644+
//
645+
// Example output: <WILDCARD>}\n
646+
parseWildcardEmpty() {
647+
// TODO: Check for WILDCARD_EMPTY
648+
this.assertToken(TokenType.LESS)
649+
650+
this.nextToken()
651+
652+
this.assertToken(TokenType.WILDCARD)
653+
654+
this.nextToken()
655+
656+
this.assertToken(TokenType.GREATER)
657+
658+
this.nextToken()
659+
660+
// TODO: Once fixed by redisearch team, remove this.
661+
this.assertToken(TokenType.RBRACE)
662+
663+
664+
return new Expr("<WILDCARD>", EntityType.WILDCARD)
665+
}
666+
633667
parseExpr() {
634668

635669
this.assertToken(TokenType.IDENTIFIER)
@@ -822,6 +856,8 @@ function Parse(data: string): SearchExpr {
822856
return p.parseIdsExpr()
823857
} else if (p.CurrentToken.T === TokenType.LEXRANGE_EXPR) {
824858
return p.parseLexrangeExpr()
859+
} else if (p.CurrentToken.T === TokenType.LESS) {
860+
return p.parseWildcardEmpty()
825861
} else {
826862
return p.parseExpr()
827863
}

0 commit comments

Comments
 (0)