1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00

(docs) add jsdoc comments to command parsers (#2984)

* (docs) bloom: add jsdocs for all commands

* (docs) json: add jsdocs

* (docs) search: add jsdocs for all commands

* (docs) jsdocs for std commands

* (docs) jsdoc comments to time series commands
This commit is contained in:
Bobby I.
2025-06-03 14:38:07 +03:00
committed by GitHub
parent e4a1ca467f
commit 20c16e0c2c
491 changed files with 3861 additions and 1 deletions

View File

@@ -141,6 +141,18 @@ export interface AggregateReply {
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: false,
/**
* Performs an aggregation query on a RediSearch index.
* @param parser - The command parser
* @param index - The index name to query
* @param query - The text query to use as filter, use * to indicate no filtering
* @param options - Optional parameters for aggregation:
* - VERBATIM: disable stemming in query evaluation
* - LOAD: specify fields to load from documents
* - STEPS: sequence of aggregation steps (GROUPBY, SORTBY, APPLY, LIMIT, FILTER)
* - PARAMS: bind parameters for query evaluation
* - TIMEOUT: maximum time to run the query
*/
parseCommand(parser: CommandParser, index: RedisArgument, query: RedisArgument, options?: FtAggregateOptions) {
parser.push('FT.AGGREGATE', index, query);

View File

@@ -19,6 +19,16 @@ export interface AggregateWithCursorReply extends AggregateReply {
export default {
IS_READ_ONLY: AGGREGATE.IS_READ_ONLY,
/**
* Performs an aggregation with a cursor for retrieving large result sets.
* @param parser - The command parser
* @param index - Name of the index to query
* @param query - The aggregation query
* @param options - Optional parameters:
* - All options supported by FT.AGGREGATE
* - COUNT: Number of results to return per cursor fetch
* - MAXIDLE: Maximum idle time for cursor in milliseconds
*/
parseCommand(parser: CommandParser, index: RedisArgument, query: RedisArgument, options?: FtAggregateWithCursorOptions) {
AGGREGATE.parseCommand(parser, index, query, options);
parser.push('WITHCURSOR');

View File

@@ -4,6 +4,12 @@ import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/li
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Adds an alias to a RediSearch index.
* @param parser - The command parser
* @param alias - The alias to add
* @param index - The index name to alias
*/
parseCommand(parser: CommandParser, alias: RedisArgument, index: RedisArgument) {
parser.push('FT.ALIASADD', alias, index);
},

View File

@@ -4,6 +4,11 @@ import { RedisArgument, SimpleStringReply, Command } from '@redis/client/dist/li
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Removes an existing alias from a RediSearch index.
* @param parser - The command parser
* @param alias - The alias to remove
*/
parseCommand(parser: CommandParser, alias: RedisArgument) {
parser.push('FT.ALIASDEL', alias);
},

View File

@@ -4,6 +4,12 @@ import { SimpleStringReply, Command, RedisArgument } from '@redis/client/dist/li
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Updates the index pointed to by an existing alias.
* @param parser - The command parser
* @param alias - The existing alias to update
* @param index - The new index name that the alias should point to
*/
parseCommand(parser: CommandParser, alias: RedisArgument, index: RedisArgument) {
parser.push('FT.ALIASUPDATE', alias, index);
},

View File

@@ -5,6 +5,12 @@ import { RediSearchSchema, parseSchema } from './CREATE';
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Alters an existing RediSearch index schema by adding new fields.
* @param parser - The command parser
* @param index - The index to alter
* @param schema - The schema definition containing new fields to add
*/
parseCommand(parser: CommandParser, index: RedisArgument, schema: RediSearchSchema) {
parser.push('FT.ALTER', index, 'SCHEMA', 'ADD');
parseSchema(parser, schema);

View File

@@ -4,6 +4,11 @@ import { ArrayReply, TuplesReply, BlobStringReply, NullReply, UnwrapReply, Comma
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Gets a RediSearch configuration option value.
* @param parser - The command parser
* @param option - The name of the configuration option to retrieve
*/
parseCommand(parser: CommandParser, option: string) {
parser.push('FT.CONFIG', 'GET', option);
},

View File

@@ -8,6 +8,12 @@ type FtConfigProperties = 'a' | 'b' | (string & {}) | Buffer;
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Sets a RediSearch configuration option value.
* @param parser - The command parser
* @param property - The name of the configuration option to set
* @param value - The value to set for the configuration option
*/
parseCommand(parser: CommandParser, property: FtConfigProperties, value: RedisArgument) {
parser.push('FT.CONFIG', 'SET', property, value);
},

View File

@@ -292,6 +292,22 @@ export interface CreateOptions {
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Creates a new search index with the given schema and options.
* @param parser - The command parser
* @param index - Name of the index to create
* @param schema - Index schema defining field names and types (TEXT, NUMERIC, GEO, TAG, VECTOR, GEOSHAPE)
* @param options - Optional parameters:
* - ON: Type of container to index (HASH or JSON)
* - PREFIX: Prefixes for document keys to index
* - FILTER: Expression that filters indexed documents
* - LANGUAGE/LANGUAGE_FIELD: Default language for indexing
* - SCORE/SCORE_FIELD: Document ranking parameters
* - MAXTEXTFIELDS: Index all text fields without specifying them
* - TEMPORARY: Create a temporary index
* - NOOFFSETS/NOHL/NOFIELDS/NOFREQS: Index optimization flags
* - STOPWORDS: Custom stopword list
*/
parseCommand(parser: CommandParser, index: RedisArgument, schema: RediSearchSchema, options?: CreateOptions) {
parser.push('FT.CREATE', index);

View File

@@ -4,6 +4,12 @@ import { SimpleStringReply, Command, RedisArgument, NumberReply, UnwrapReply } f
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Deletes a cursor from an index.
* @param parser - The command parser
* @param index - The index name that contains the cursor
* @param cursorId - The cursor ID to delete
*/
parseCommand(parser: CommandParser, index: RedisArgument, cursorId: UnwrapReply<NumberReply>) {
parser.push('FT.CURSOR', 'DEL', index, cursorId.toString());
},

View File

@@ -9,6 +9,14 @@ export interface FtCursorReadOptions {
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Reads from an existing cursor to get more results from an index.
* @param parser - The command parser
* @param index - The index name that contains the cursor
* @param cursor - The cursor ID to read from
* @param options - Optional parameters:
* - COUNT: Maximum number of results to return
*/
parseCommand(parser: CommandParser, index: RedisArgument, cursor: UnwrapReply<NumberReply>, options?: FtCursorReadOptions) {
parser.push('FT.CURSOR', 'READ', index, cursor.toString());

View File

@@ -5,6 +5,12 @@ import { RedisVariadicArgument } from '@redis/client/dist/lib/commands/generic-t
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Adds terms to a dictionary.
* @param parser - The command parser
* @param dictionary - Name of the dictionary to add terms to
* @param term - One or more terms to add to the dictionary
*/
parseCommand(parser: CommandParser, dictionary: RedisArgument, term: RedisVariadicArgument) {
parser.push('FT.DICTADD', dictionary);
parser.pushVariadic(term);

View File

@@ -5,6 +5,12 @@ import { RedisVariadicArgument } from '@redis/client/dist/lib/commands/generic-t
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Deletes terms from a dictionary.
* @param parser - The command parser
* @param dictionary - Name of the dictionary to remove terms from
* @param term - One or more terms to delete from the dictionary
*/
parseCommand(parser: CommandParser, dictionary: RedisArgument, term: RedisVariadicArgument) {
parser.push('FT.DICTDEL', dictionary);
parser.pushVariadic(term);

View File

@@ -4,6 +4,11 @@ import { RedisArgument, ArrayReply, SetReply, BlobStringReply, Command } from '@
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Returns all terms in a dictionary.
* @param parser - The command parser
* @param dictionary - Name of the dictionary to dump
*/
parseCommand(parser: CommandParser, dictionary: RedisArgument) {
parser.push('FT.DICTDUMP', dictionary);
},

View File

@@ -8,6 +8,13 @@ export interface FtDropIndexOptions {
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Deletes an index and all associated documents.
* @param parser - The command parser
* @param index - Name of the index to delete
* @param options - Optional parameters:
* - DD: Also delete the indexed documents themselves
*/
parseCommand(parser: CommandParser, index: RedisArgument, options?: FtDropIndexOptions) {
parser.push('FT.DROPINDEX', index);

View File

@@ -11,6 +11,15 @@ export interface FtExplainOptions {
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Returns the execution plan for a complex query.
* @param parser - The command parser
* @param index - Name of the index to explain query against
* @param query - The query string to explain
* @param options - Optional parameters:
* - PARAMS: Named parameters to use in the query
* - DIALECT: Version of query dialect to use (defaults to 1)
*/
parseCommand(
parser: CommandParser,
index: RedisArgument,

View File

@@ -9,6 +9,14 @@ export interface FtExplainCLIOptions {
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Returns the execution plan for a complex query in a more verbose format than FT.EXPLAIN.
* @param parser - The command parser
* @param index - Name of the index to explain query against
* @param query - The query string to explain
* @param options - Optional parameters:
* - DIALECT: Version of query dialect to use (defaults to 1)
*/
parseCommand(
parser: CommandParser,
index: RedisArgument,

View File

@@ -7,6 +7,11 @@ import { TuplesReply } from '@redis/client/dist/lib/RESP/types';
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Returns information and statistics about an index.
* @param parser - The command parser
* @param index - Name of the index to get information about
*/
parseCommand(parser: CommandParser, index: RedisArgument) {
parser.push('FT.INFO', index);
},

View File

@@ -6,6 +6,15 @@ import { ProfileOptions, ProfileRawReplyResp2, ProfileReplyResp2, } from './PROF
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Profiles the execution of an aggregation query for performance analysis.
* @param parser - The command parser
* @param index - Name of the index to profile query against
* @param query - The aggregation query to profile
* @param options - Optional parameters:
* - LIMITED: Collect limited timing information only
* - All options supported by FT.AGGREGATE command
*/
parseCommand(
parser: CommandParser,
index: string,

View File

@@ -22,6 +22,15 @@ export interface ProfileOptions {
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Profiles the execution of a search query for performance analysis.
* @param parser - The command parser
* @param index - Name of the index to profile query against
* @param query - The search query to profile
* @param options - Optional parameters:
* - LIMITED: Collect limited timing information only
* - All options supported by FT.SEARCH command
*/
parseCommand(
parser: CommandParser,
index: RedisArgument,

View File

@@ -161,6 +161,21 @@ export function parseSearchOptions(parser: CommandParser, options?: FtSearchOpti
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Searches a RediSearch index with the given query.
* @param parser - The command parser
* @param index - The index name to search
* @param query - The text query to search. For syntax, see https://redis.io/docs/stack/search/reference/query_syntax
* @param options - Optional search parameters including:
* - VERBATIM: do not try to use stemming for query expansion
* - NOSTOPWORDS: do not filter stopwords from the query
* - INKEYS/INFIELDS: restrict the search to specific keys/fields
* - RETURN: limit which fields are returned
* - SUMMARIZE/HIGHLIGHT: create search result highlights
* - LIMIT: pagination control
* - SORTBY: sort results by a specific field
* - PARAMS: bind parameters to the query
*/
parseCommand(parser: CommandParser, index: RedisArgument, query: RedisArgument, options?: FtSearchOptions) {
parser.push('FT.SEARCH', index, query);

View File

@@ -4,6 +4,14 @@ import SEARCH, { SearchRawReply } from './SEARCH';
export default {
NOT_KEYED_COMMAND: SEARCH.NOT_KEYED_COMMAND,
IS_READ_ONLY: SEARCH.IS_READ_ONLY,
/**
* Performs a search query but returns only document ids without their contents.
* @param args - Same parameters as FT.SEARCH:
* - parser: The command parser
* - index: Name of the index to search
* - query: The text query to search
* - options: Optional search parameters
*/
parseCommand(...args: Parameters<typeof SEARCH.parseCommand>) {
SEARCH.parseCommand(...args);
args[0].push('NOCONTENT');

View File

@@ -16,6 +16,16 @@ export interface FtSpellCheckOptions {
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Performs spelling correction on a search query.
* @param parser - The command parser
* @param index - Name of the index to use for spelling corrections
* @param query - The search query to check for spelling
* @param options - Optional parameters:
* - DISTANCE: Maximum Levenshtein distance for spelling suggestions
* - TERMS: Custom dictionary terms to include/exclude
* - DIALECT: Version of query dialect to use (defaults to 1)
*/
parseCommand(parser: CommandParser, index: RedisArgument, query: RedisArgument, options?: FtSpellCheckOptions) {
parser.push('FT.SPELLCHECK', index, query);

View File

@@ -8,6 +8,16 @@ export interface FtSugAddOptions {
export default {
IS_READ_ONLY: true,
/**
* Adds a suggestion string to an auto-complete suggestion dictionary.
* @param parser - The command parser
* @param key - The suggestion dictionary key
* @param string - The suggestion string to add
* @param score - The suggestion score used for sorting
* @param options - Optional parameters:
* - INCR: If true, increment the existing entry's score
* - PAYLOAD: Optional payload to associate with the suggestion
*/
parseCommand(parser: CommandParser, key: RedisArgument, string: RedisArgument, score: number, options?: FtSugAddOptions) {
parser.push('FT.SUGADD');
parser.pushKey(key);

View File

@@ -3,6 +3,12 @@ import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP
export default {
IS_READ_ONLY: true,
/**
* Deletes a string from a suggestion dictionary.
* @param parser - The command parser
* @param key - The suggestion dictionary key
* @param string - The suggestion string to delete
*/
parseCommand(parser: CommandParser, key: RedisArgument, string: RedisArgument) {
parser.push('FT.SUGDEL');
parser.pushKey(key);

View File

@@ -8,6 +8,15 @@ export interface FtSugGetOptions {
export default {
IS_READ_ONLY: true,
/**
* Gets completion suggestions for a prefix from a suggestion dictionary.
* @param parser - The command parser
* @param key - The suggestion dictionary key
* @param prefix - The prefix to get completion suggestions for
* @param options - Optional parameters:
* - FUZZY: Enable fuzzy prefix matching
* - MAX: Maximum number of results to return
*/
parseCommand(parser: CommandParser, key: RedisArgument, prefix: RedisArgument, options?: FtSugGetOptions) {
parser.push('FT.SUGGET');
parser.pushKey(key);

View File

@@ -4,6 +4,14 @@ import SUGGET from './SUGGET';
export default {
IS_READ_ONLY: SUGGET.IS_READ_ONLY,
/**
* Gets completion suggestions with their payloads from a suggestion dictionary.
* @param args - Same parameters as FT.SUGGET:
* - parser: The command parser
* - key: The suggestion dictionary key
* - prefix: The prefix to get completion suggestions for
* - options: Optional parameters for fuzzy matching and max results
*/
parseCommand(...args: Parameters<typeof SUGGET.parseCommand>) {
SUGGET.parseCommand(...args);
args[0].push('WITHPAYLOADS');

View File

@@ -9,6 +9,14 @@ type SuggestScore = {
export default {
IS_READ_ONLY: SUGGET.IS_READ_ONLY,
/**
* Gets completion suggestions with their scores from a suggestion dictionary.
* @param args - Same parameters as FT.SUGGET:
* - parser: The command parser
* - key: The suggestion dictionary key
* - prefix: The prefix to get completion suggestions for
* - options: Optional parameters for fuzzy matching and max results
*/
parseCommand(...args: Parameters<typeof SUGGET.parseCommand>) {
SUGGET.parseCommand(...args);
args[0].push('WITHSCORES');

View File

@@ -10,6 +10,14 @@ type SuggestScoreWithPayload = {
export default {
IS_READ_ONLY: SUGGET.IS_READ_ONLY,
/**
* Gets completion suggestions with their scores and payloads from a suggestion dictionary.
* @param args - Same parameters as FT.SUGGET:
* - parser: The command parser
* - key: The suggestion dictionary key
* - prefix: The prefix to get completion suggestions for
* - options: Optional parameters for fuzzy matching and max results
*/
parseCommand(...args: Parameters<typeof SUGGET.parseCommand>) {
SUGGET.parseCommand(...args);
args[0].push(

View File

@@ -3,6 +3,11 @@ import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP
export default {
IS_READ_ONLY: true,
/**
* Gets the size of a suggestion dictionary.
* @param parser - The command parser
* @param key - The suggestion dictionary key
*/
parseCommand(parser: CommandParser, key: RedisArgument) {
parser.push('FT.SUGLEN', key);
},

View File

@@ -4,6 +4,11 @@ import { RedisArgument, MapReply, BlobStringReply, ArrayReply, UnwrapReply, Comm
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Dumps the contents of a synonym group.
* @param parser - The command parser
* @param index - Name of the index that contains the synonym group
*/
parseCommand(parser: CommandParser, index: RedisArgument) {
parser.push('FT.SYNDUMP', index);
},

View File

@@ -9,6 +9,15 @@ export interface FtSynUpdateOptions {
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Updates a synonym group with new terms.
* @param parser - The command parser
* @param index - Name of the index that contains the synonym group
* @param groupId - ID of the synonym group to update
* @param terms - One or more synonym terms to add to the group
* @param options - Optional parameters:
* - SKIPINITIALSCAN: Skip the initial scan for existing documents
*/
parseCommand(
parser: CommandParser,
index: RedisArgument,

View File

@@ -4,6 +4,12 @@ import { RedisArgument, ArrayReply, SetReply, BlobStringReply, Command } from '@
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Returns the distinct values in a TAG field.
* @param parser - The command parser
* @param index - Name of the index
* @param fieldName - Name of the TAG field to get values from
*/
parseCommand(parser: CommandParser, index: RedisArgument, fieldName: RedisArgument) {
parser.push('FT.TAGVALS', index, fieldName);
},

View File

@@ -4,6 +4,10 @@ import { ArrayReply, SetReply, BlobStringReply, Command } from '@redis/client/di
export default {
NOT_KEYED_COMMAND: true,
IS_READ_ONLY: true,
/**
* Lists all existing indexes in the database.
* @param parser - The command parser
*/
parseCommand(parser: CommandParser) {
parser.push('FT._LIST');
},