Skip to content

Commit 04ff38a

Browse files
DOC-5801: search: add new FT.HYBRID command (#2210)
* DOC-5801: search: add new FT.HYBRID command * Add compat. info * Fixed commands.json parsing; updated FT.HYBRID syntax * Apply suggestions from code review Co-authored-by: adrianoamaral <adriano.amaral@redis.com> * Update content/commands/ft.hybrid.md Co-authored-by: adrianoamaral <adriano.amaral@redis.com> * Fix build error and provide more copy-editing * Fix compat. heading --------- Co-authored-by: adrianoamaral <adriano.amaral@redis.com>
1 parent 88a25c7 commit 04ff38a

File tree

2 files changed

+627
-2
lines changed

2 files changed

+627
-2
lines changed

build/components/syntax.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ class ArgumentType(Enum):
2020
BLOCK = 'block'
2121
PURE_TOKEN = 'pure-token'
2222
COMMAND = 'command'
23+
FUNCTION = 'function'
24+
INDEX = 'index'
25+
KEYNUM = 'keynum'
26+
KEYWORD = 'keyword'
27+
RANGE = 'range'
28+
UNKNOWN = 'unknown'
2329

2430

2531
class Argument:
@@ -28,8 +34,8 @@ def __init__(self, data: dict = {}, level: int = 0, max_width: int = 640) -> Non
2834
self._stack = []
2935
self._level: int = level
3036
self._max_width: int = max_width
31-
self._name: str = data['name']
32-
self._type = ArgumentType(data['type'])
37+
self._name: str = data.get('name', data.get('token', 'unnamed'))
38+
self._type = ArgumentType(data.get('type', 'string'))
3339
self._optional: bool = data.get('optional', False)
3440
self._multiple: bool = data.get('multiple', False)
3541
self._multiple_token: bool = data.get('multiple_token', False)
@@ -49,6 +55,11 @@ def syntax(self, **kwargs) -> str:
4955
args += ' '.join([arg.syntax() for arg in self._arguments])
5056
elif self._type == ArgumentType.ONEOF:
5157
args += f' | '.join([arg.syntax() for arg in self._arguments])
58+
elif self._type == ArgumentType.FUNCTION:
59+
# Functions should display their token/name, not expand nested arguments
60+
args += self._display
61+
if show_types:
62+
args += f':{self._type.value}'
5263
elif self._type != ArgumentType.PURE_TOKEN:
5364
args += self._display
5465
if show_types:

0 commit comments

Comments
 (0)