Skip to content

Commit 8061819

Browse files
committed
Fixed commands.json parsing; updated FT.HYBRID syntax
1 parent b41e74f commit 8061819

File tree

2 files changed

+31
-12
lines changed

2 files changed

+31
-12
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:

content/commands/ft.hybrid.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -284,20 +284,28 @@ categories:
284284
- oss
285285
- kubernetes
286286
- clients
287-
command_flags:
288-
- readonly
289-
complexity: O(N)
290-
description: Performs hybrid search combining text search and vector similarity with configurable fusion methods
287+
complexity: O(N+M) where N is the complexity of the text search and M is the complexity
288+
of the vector search
289+
description: Performs hybrid search combining text search and vector similarity search
291290
group: search
292291
hidden: false
293292
linkTitle: FT.HYBRID
294-
module: Search
295293
since: 8.4.0
296-
stack_path: docs/interact/search-and-query
297-
summary: Performs hybrid search combining text search and vector similarity with configurable fusion methods
298-
syntax: "FT.HYBRID index \n SEARCH \"<search-expression>\" \n [SCORER algorithm params...] \n [YIELD_SCORE_AS <alias-search-score>] \n VSIM @vector_field \"<vector-data>\" \n [KNN <count> K <topk-k> [EF_RUNTIME <ef-value>] [YIELD_DISTANCE_AS <distance_field>]] \n [RANGE <count> RADIUS <radius-value> [EPSILON <epsilon-value>] [YIELD_DISTANCE_AS <distance_field>]] \n [FILTER \"<filter-expression>\"] \n [POLICY [ADHOC|BATCHES|ACORN] [BATCH_SIZE <batch-size-value>]] \n [COMBINE method params...] \n [RRF <count> [WINDOW <value>] [CONSTANT <value>]] \n [LINEAR <count> [ALPHA <value>] [BETA <value>]] \n [YIELD_SCORE_AS <alias-combined-score>] \n [LOAD <count> field...] \n [GROUPBY <count> field... REDUCE function...] \n [APPLY expression AS field] \n [SORTBY field [ASC|DESC]] \n [FILTER <post-filter-expression>] \n [LIMIT offset num] \n [PARAMS <count> key value...] \n [EXPLAINSCORE] \n [TIMEOUT timeout] \n [WITHCURSOR [COUNT read_size] [MAXIDLE idle_time]]\n"
299-
syntax_fmt: "FT.HYBRID index SEARCH \"<search-expression>\" [SCORER\_algorithm\n params...] [YIELD_SCORE_AS\_<alias-search-score>] VSIM @vector_field\n \"<vector-data>\" [KNN\_<count> K\_<topk-k> [EF_RUNTIME\_<ef-value>]\n [YIELD_DISTANCE_AS\_<distance_field>]] [RANGE\_<count> RADIUS\_<radius-value>\n [EPSILON\_<epsilon-value>] [YIELD_DISTANCE_AS\_<distance_field>]]\n [FILTER\_\"<filter-expression>\"] [POLICY\_[ADHOC|BATCHES|ACORN]\n [BATCH_SIZE\_<batch-size-value>]] [COMBINE\_method params...]\n [RRF\_<count> [WINDOW\_<value>] [CONSTANT\_<value>]] [LINEAR\_<count>\n [ALPHA\_<value>] [BETA\_<value>]] [YIELD_SCORE_AS\_<alias-combined-score>]\n [LOAD\_<count> field...] [GROUPBY\_<count> field... REDUCE\_function...]\n [APPLY\_expression AS\_field] [SORTBY\_field [ASC|DESC]]\n [FILTER\_<post-filter-expression>] [LIMIT\_offset num] [PARAMS\_<count>\n key value...] [EXPLAINSCORE] [TIMEOUT\_timeout] [WITHCURSOR [COUNT\_read_size]\n [MAXIDLE\_idle_time]]"
300-
syntax_str: "SEARCH \"<search-expression>\" [SCORER\_algorithm params...] [YIELD_SCORE_AS\_<alias-search-score>] VSIM @vector_field \"<vector-data>\" [KNN\_<count> K\_<topk-k> [EF_RUNTIME\_<ef-value>] [YIELD_DISTANCE_AS\_<distance_field>]] [RANGE\_<count> RADIUS\_<radius-value> [EPSILON\_<epsilon-value>] [YIELD_DISTANCE_AS\_<distance_field>]] [FILTER\_\"<filter-expression>\"] [POLICY\_[ADHOC|BATCHES|ACORN] [BATCH_SIZE\_<batch-size-value>]] [COMBINE\_method params...] [RRF\_<count> [WINDOW\_<value>] [CONSTANT\_<value>]] [LINEAR\_<count> [ALPHA\_<value>] [BETA\_<value>]] [YIELD_SCORE_AS\_<alias-combined-score>] [LOAD\_<count> field...] [GROUPBY\_<count> field... REDUCE\_function...] [APPLY\_expression AS\_field] [SORTBY\_field [ASC|DESC]] [FILTER\_<post-filter-expression>] [LIMIT\_offset num] [PARAMS\_<count> key value...] [EXPLAINSCORE] [TIMEOUT\_timeout] [WITHCURSOR [COUNT\_read_size] [MAXIDLE\_idle_time]]"
294+
summary: Performs hybrid search combining text search and vector similarity search
295+
syntax_fmt: "FT.HYBRID index SEARCH query [SCORER\_scorer]\n [YIELD_SCORE_AS\_yield_score_as]\
296+
\ VSIM field vector [KNN count K\_k\n [EF_RUNTIME\_ef_runtime] [YIELD_SCORE_AS\_\
297+
yield_score_as] | RANGE\n count RADIUS\_radius [EPSILON\_epsilon]\n [YIELD_SCORE_AS\_\
298+
yield_score_as]] [FILTER\_filter] [COMBINE <RRF\n count [CONSTANT\_constant] [WINDOW\_\
299+
window]\n [YIELD_SCORE_AS\_yield_score_as] | LINEAR count [ALPHA\_alpha\n BETA\_\
300+
beta] [WINDOW\_window] [YIELD_SCORE_AS\_yield_score_as]>]\n [LIMIT offset num]\
301+
\ [SORTBY\_sortby [ASC | DESC] | NOSORT] [PARAMS\n nargs name value [name value\
302+
\ ...]] [TIMEOUT\_timeout]\n [FORMAT\_format] [LOAD\_count field [field ...]] [LOAD\
303+
\ *] [GROUPBY\n nproperties property [property ...] [REDUCE <COUNT |\n COUNT_DISTINCT\
304+
\ | COUNT_DISTINCTISH | SUM | MIN | MAX | AVG |\n STDDEV | QUANTILE | TOLIST |\
305+
\ FIRST_VALUE | RANDOM_SAMPLE> nargs\n arg [arg ...] [AS\_name] [REDUCE <COUNT\
306+
\ | COUNT_DISTINCT |\n COUNT_DISTINCTISH | SUM | MIN | MAX | AVG | STDDEV | QUANTILE\
307+
\ |\n TOLIST | FIRST_VALUE | RANDOM_SAMPLE> nargs arg [arg ...]\n [AS\_name] ...]]]\
308+
\ [APPLY\_expression AS\_name [APPLY\_expression\n AS\_name ...]] [FILTER\_filter]"
301309
title: FT.HYBRID
302310
---
303311

0 commit comments

Comments
 (0)