Socket
Socket
Sign inDemoInstall

@node-redis/search

Package Overview
Dependencies
6
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.4 to 1.0.5

4

dist/commands/AGGREGATE.d.ts
import { RedisCommandArgument, RedisCommandArguments } from '@node-redis/client/dist/lib/commands';
import { PropertyName, SortByProperty } from '.';
import { Params, PropertyName, SortByProperty } from '.';
export declare enum AggregateSteps {

@@ -100,2 +100,4 @@ GROUPBY = "GROUPBY",

STEPS?: Array<GroupByStep | SortStep | ApplyStep | LimitStep | FilterStep>;
PARAMS?: Params;
DIALECT?: number;
}

@@ -102,0 +104,0 @@ export declare function transformArguments(index: string, query: string, options?: AggregateOptions): RedisCommandArguments;

@@ -31,5 +31,3 @@ "use strict";

function transformArguments(index, query, options) {
const args = ['FT.AGGREGATE', index, query];
pushAggregatehOptions(args, options);
return args;
return pushAggregatehOptions(['FT.AGGREGATE', index, query], options);
}

@@ -92,2 +90,6 @@ exports.transformArguments = transformArguments;

}
(0, _1.pushParamsArgs)(args, options === null || options === void 0 ? void 0 : options.PARAMS);
if (options === null || options === void 0 ? void 0 : options.DIALECT) {
args.push('DIALECT', options.DIALECT.toString());
}
return args;

@@ -94,0 +96,0 @@ }

@@ -0,3 +1,9 @@

import { Params } from ".";
export declare const IS_READ_ONLY = true;
export declare function transformArguments(index: string, query: string): Array<string>;
interface ExplainOptions {
PARAMS?: Params;
DIALECT?: number;
}
export declare function transformArguments(index: string, query: string, options?: ExplainOptions): Array<string>;
export declare function transformReply(): string;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArguments = exports.IS_READ_ONLY = void 0;
const _1 = require(".");
exports.IS_READ_ONLY = true;
function transformArguments(index, query) {
return ['FT.EXPLAIN', index, query];
function transformArguments(index, query, options) {
const args = ['FT.EXPLAIN', index, query];
(0, _1.pushParamsArgs)(args, options === null || options === void 0 ? void 0 : options.PARAMS);
if (options === null || options === void 0 ? void 0 : options.DIALECT) {
args.push('DIALECT', options.DIALECT.toString());
}
return args;
}
exports.transformArguments = transformArguments;

@@ -31,3 +31,3 @@ import * as _LIST from './_LIST';

import * as TAGVALS from './TAGVALS';
import { RedisCommandArguments } from '@node-redis/client/dist/lib/commands';
import { RedisCommandArgument, RedisCommandArguments } from '@node-redis/client/dist/lib/commands';
import { SearchOptions } from './SEARCH';

@@ -136,3 +136,4 @@ declare const _default: {

GEO = "GEO",
TAG = "TAG"
TAG = "TAG",
VECTOR = "VECTOR"
}

@@ -142,5 +143,7 @@ declare type CreateSchemaField<T extends SchemaFieldTypes, E = Record<keyof any, any>> = T | ({

AS?: string;
} & E);
declare type CreateSchemaCommonField<T extends SchemaFieldTypes, E = Record<string, never>> = CreateSchemaField<T, ({
SORTABLE?: true | 'UNF';
NOINDEX?: true;
} & E);
} & E)>;
export declare enum SchemaTextFieldPhonetics {

@@ -152,3 +155,3 @@ DM_EN = "dm:en",

}
declare type CreateSchemaTextField = CreateSchemaField<SchemaFieldTypes.TEXT, {
declare type CreateSchemaTextField = CreateSchemaCommonField<SchemaFieldTypes.TEXT, {
NOSTEM?: true;

@@ -158,12 +161,33 @@ WEIGHT?: number;

}>;
declare type CreateSchemaNumericField = CreateSchemaField<SchemaFieldTypes.NUMERIC>;
declare type CreateSchemaGeoField = CreateSchemaField<SchemaFieldTypes.GEO>;
declare type CreateSchemaTagField = CreateSchemaField<SchemaFieldTypes.TAG, {
declare type CreateSchemaNumericField = CreateSchemaCommonField<SchemaFieldTypes.NUMERIC>;
declare type CreateSchemaGeoField = CreateSchemaCommonField<SchemaFieldTypes.GEO>;
declare type CreateSchemaTagField = CreateSchemaCommonField<SchemaFieldTypes.TAG, {
SEPARATOR?: string;
CASESENSITIVE?: true;
}>;
export declare enum VectorAlgorithms {
FLAT = "FLAT",
HNSW = "HNSW"
}
declare type CreateSchemaVectorField<T extends VectorAlgorithms, A extends Record<string, unknown>> = CreateSchemaField<SchemaFieldTypes.VECTOR, {
ALGORITHM: T;
TYPE: string;
DIM: number;
DISTANCE_METRIC: 'L2' | 'IP' | 'COSINE';
INITIAL_CAP?: number;
} & A>;
declare type CreateSchemaFlatVectorField = CreateSchemaVectorField<VectorAlgorithms.FLAT, {
BLOCK_SIZE?: number;
}>;
declare type CreateSchemaHNSWVectorField = CreateSchemaVectorField<VectorAlgorithms.HNSW, {
M?: number;
EF_CONSTRUCTION?: number;
EF_RUNTIME?: number;
}>;
export interface RediSearchSchema {
[field: string]: CreateSchemaTextField | CreateSchemaNumericField | CreateSchemaGeoField | CreateSchemaTagField;
[field: string]: CreateSchemaTextField | CreateSchemaNumericField | CreateSchemaGeoField | CreateSchemaTagField | CreateSchemaFlatVectorField | CreateSchemaHNSWVectorField;
}
export declare function pushSchema(args: RedisCommandArguments, schema: RediSearchSchema): void;
export declare type Params = Record<string, RedisCommandArgument | number>;
export declare function pushParamsArgs(args: RedisCommandArguments, params?: Params): RedisCommandArguments;
export declare function pushSearchOptions(args: RedisCommandArguments, options?: SearchOptions): RedisCommandArguments;

@@ -170,0 +194,0 @@ interface SearchDocumentValue {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformProfile = exports.pushSearchOptions = exports.pushSchema = exports.SchemaTextFieldPhonetics = exports.SchemaFieldTypes = exports.pushArgumentsWithLength = exports.pushSortByArguments = exports.pushSortByProperty = exports.RedisSearchLanguages = void 0;
exports.transformProfile = exports.pushSearchOptions = exports.pushParamsArgs = exports.pushSchema = exports.VectorAlgorithms = exports.SchemaTextFieldPhonetics = exports.SchemaFieldTypes = exports.pushArgumentsWithLength = exports.pushSortByArguments = exports.pushSortByProperty = exports.RedisSearchLanguages = void 0;
const _LIST = require("./_LIST");

@@ -165,2 +165,3 @@ const ALTER = require("./ALTER");

SchemaFieldTypes["TAG"] = "TAG";
SchemaFieldTypes["VECTOR"] = "VECTOR";
})(SchemaFieldTypes = exports.SchemaFieldTypes || (exports.SchemaFieldTypes = {}));

@@ -174,2 +175,7 @@ var SchemaTextFieldPhonetics;

})(SchemaTextFieldPhonetics = exports.SchemaTextFieldPhonetics || (exports.SchemaTextFieldPhonetics = {}));
var VectorAlgorithms;
(function (VectorAlgorithms) {
VectorAlgorithms["FLAT"] = "FLAT";
VectorAlgorithms["HNSW"] = "HNSW";
})(VectorAlgorithms = exports.VectorAlgorithms || (exports.VectorAlgorithms = {}));
function pushSchema(args, schema) {

@@ -209,2 +215,29 @@ for (const [field, fieldOptions] of Object.entries(schema)) {

break;
case SchemaFieldTypes.VECTOR:
args.push(fieldOptions.ALGORITHM);
pushArgumentsWithLength(args, () => {
args.push('TYPE', fieldOptions.TYPE, 'DIM', fieldOptions.DIM.toString(), 'DISTANCE_METRIC', fieldOptions.DISTANCE_METRIC);
if (fieldOptions.INITIAL_CAP) {
args.push('INITIAL_CAP', fieldOptions.INITIAL_CAP.toString());
}
switch (fieldOptions.ALGORITHM) {
case VectorAlgorithms.FLAT:
if (fieldOptions.BLOCK_SIZE) {
args.push('BLOCK_SIZE', fieldOptions.BLOCK_SIZE.toString());
}
break;
case VectorAlgorithms.HNSW:
if (fieldOptions.M) {
args.push('M', fieldOptions.M.toString());
}
if (fieldOptions.EF_CONSTRUCTION) {
args.push('EF_CONSTRUCTION', fieldOptions.EF_CONSTRUCTION.toString());
}
if (fieldOptions.EF_RUNTIME) {
args.push('EF_RUNTIME', fieldOptions.EF_RUNTIME.toString());
}
break;
}
});
continue; // vector fields do not contain SORTABLE and NOINDEX options
}

@@ -223,2 +256,13 @@ if (fieldOptions.SORTABLE) {

exports.pushSchema = pushSchema;
function pushParamsArgs(args, params) {
if (params) {
const enrties = Object.entries(params);
args.push('PARAMS', (enrties.length * 2).toString());
for (const [key, value] of enrties) {
args.push(key, value.toString());
}
}
return args;
}
exports.pushParamsArgs = pushParamsArgs;
function pushSearchOptions(args, options) {

@@ -301,2 +345,9 @@ if (options === null || options === void 0 ? void 0 : options.VERBATIM) {

}
if (options === null || options === void 0 ? void 0 : options.PARAMS) {
pushParamsArgs(args, options.PARAMS);
}
if (options === null || options === void 0 ? void 0 : options.DIALECT) {
args.push('DIALECT', options.DIALECT.toString());
}
console.log('!@#', args);
return args;

@@ -303,0 +354,0 @@ }

@@ -0,115 +1,110 @@

import { RedisCommandArgument } from '@node-redis/client/dist/lib/commands';
export declare function transformArguments(index: string): Array<string>;
declare type InfoRawReply = [
_: string,
indexName: string,
_: string,
indexOptions: Array<string>,
_: string,
indexDefinition: [
_: string,
keyType: string,
_: string,
prefixes: Array<string>,
_: string,
defaultScore: string
'index_name',
RedisCommandArgument,
'index_options',
Array<RedisCommandArgument>,
'index_definition',
Array<RedisCommandArgument>,
'attributes',
Array<Array<RedisCommandArgument>>,
'num_docs',
RedisCommandArgument,
'max_doc_id',
RedisCommandArgument,
'num_terms',
RedisCommandArgument,
'num_records',
RedisCommandArgument,
'inverted_sz_mb',
RedisCommandArgument,
'vector_index_sz_mb',
RedisCommandArgument,
'total_inverted_index_blocks',
RedisCommandArgument,
'offset_vectors_sz_mb',
RedisCommandArgument,
'doc_table_size_mb',
RedisCommandArgument,
'sortable_values_size_mb',
RedisCommandArgument,
'key_table_size_mb',
RedisCommandArgument,
'records_per_doc_avg',
RedisCommandArgument,
'bytes_per_record_avg',
RedisCommandArgument,
'offsets_per_term_avg',
RedisCommandArgument,
'offset_bits_per_record_avg',
RedisCommandArgument,
'hash_indexing_failures',
RedisCommandArgument,
'indexing',
RedisCommandArgument,
'percent_indexed',
RedisCommandArgument,
'gc_stats',
[
'bytes_collected',
RedisCommandArgument,
'total_ms_run',
RedisCommandArgument,
'total_cycles',
RedisCommandArgument,
'average_cycle_time_ms',
RedisCommandArgument,
'last_run_time_ms',
RedisCommandArgument,
'gc_numeric_trees_missed',
RedisCommandArgument,
'gc_blocks_denied',
RedisCommandArgument
],
_: string,
attributes: Array<Array<string>>,
_: string,
numDocs: string,
_: string,
maxDocId: string,
_: string,
numTerms: string,
_: string,
numRecords: string,
_: string,
invertedSzMb: string,
_: string,
totalInvertedIndexBlocks: string,
_: string,
offsetVectorsSzMb: string,
_: string,
docTableSizeMb: string,
_: string,
sortableValuesSizeMb: string,
_: string,
keyTableSizeMb: string,
_: string,
recordsPerDocAvg: string,
_: string,
bytesPerRecordAvg: string,
_: string,
offsetsPerTermAvg: string,
_: string,
offsetBitsPerRecordAvg: string,
_: string,
hashIndexingFailures: string,
_: string,
indexing: string,
_: string,
percentIndexed: string,
_: string,
gcStats: [
_: string,
bytesCollected: string,
_: string,
totalMsRun: string,
_: string,
totalCycles: string,
_: string,
averageCycleTimeMs: string,
_: string,
lastRunTimeMs: string,
_: string,
gcNumericTreesMissed: string,
_: string,
gcBlocksDenied: string
'cursor_stats',
[
'global_idle',
number,
'global_total',
number,
'index_capacity',
number,
'index_total',
number
],
_: string,
cursorStats: [
_: string,
globalIdle: number,
_: string,
globalTotal: number,
_: string,
indexCapacity: number,
_: string,
idnexTotal: number
]
'stopwords_list'?,
Array<RedisCommandArgument>?
];
interface InfoReply {
indexName: string;
indexOptions: Array<string>;
indexDefinition: {
keyType: string;
prefixes: Array<string>;
defaultScore: string;
};
attributes: Array<Array<string>>;
numDocs: string;
maxDocId: string;
numTerms: string;
numRecords: string;
invertedSzMb: string;
totalInvertedIndexBlocks: string;
offsetVectorsSzMb: string;
docTableSizeMb: string;
sortableValuesSizeMb: string;
keyTableSizeMb: string;
recordsPerDocAvg: string;
bytesPerRecordAvg: string;
offsetsPerTermAvg: string;
offsetBitsPerRecordAvg: string;
hashIndexingFailures: string;
indexing: string;
percentIndexed: string;
indexName: RedisCommandArgument;
indexOptions: Array<RedisCommandArgument>;
indexDefinition: Record<string, RedisCommandArgument>;
attributes: Array<Record<string, RedisCommandArgument>>;
numDocs: RedisCommandArgument;
maxDocId: RedisCommandArgument;
numTerms: RedisCommandArgument;
numRecords: RedisCommandArgument;
invertedSzMb: RedisCommandArgument;
vectorIndexSzMb: RedisCommandArgument;
totalInvertedIndexBlocks: RedisCommandArgument;
offsetVectorsSzMb: RedisCommandArgument;
docTableSizeMb: RedisCommandArgument;
sortableValuesSizeMb: RedisCommandArgument;
keyTableSizeMb: RedisCommandArgument;
recordsPerDocAvg: RedisCommandArgument;
bytesPerRecordAvg: RedisCommandArgument;
offsetsPerTermAvg: RedisCommandArgument;
offsetBitsPerRecordAvg: RedisCommandArgument;
hashIndexingFailures: RedisCommandArgument;
indexing: RedisCommandArgument;
percentIndexed: RedisCommandArgument;
gcStats: {
bytesCollected: string;
totalMsRun: string;
totalCycles: string;
averageCycleTimeMs: string;
lastRunTimeMs: string;
gcNumericTreesMissed: string;
gcBlocksDenied: string;
bytesCollected: RedisCommandArgument;
totalMsRun: RedisCommandArgument;
totalCycles: RedisCommandArgument;
averageCycleTimeMs: RedisCommandArgument;
lastRunTimeMs: RedisCommandArgument;
gcNumericTreesMissed: RedisCommandArgument;
gcBlocksDenied: RedisCommandArgument;
};

@@ -122,4 +117,5 @@ cursorStats: {

};
stopWords: Array<RedisCommandArgument> | undefined;
}
export declare function transformReply(rawReply: InfoRawReply): InfoReply;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformReply = exports.transformArguments = void 0;
const generic_transformers_1 = require("@node-redis/client/dist/lib/commands/generic-transformers");
function transformArguments(index) {

@@ -9,11 +10,8 @@ return ['FT.INFO', index];

function transformReply(rawReply) {
console.log(rawReply);
return {
indexName: rawReply[1],
indexOptions: rawReply[3],
indexDefinition: {
keyType: rawReply[5][1],
prefixes: rawReply[5][3],
defaultScore: rawReply[5][5]
},
attributes: rawReply[7],
indexDefinition: (0, generic_transformers_1.transformTuplesReply)(rawReply[5]),
attributes: rawReply[7].map(attribute => (0, generic_transformers_1.transformTuplesReply)(attribute)),
numDocs: rawReply[9],

@@ -24,31 +22,33 @@ maxDocId: rawReply[11],

invertedSzMb: rawReply[17],
totalInvertedIndexBlocks: rawReply[19],
offsetVectorsSzMb: rawReply[21],
docTableSizeMb: rawReply[23],
sortableValuesSizeMb: rawReply[25],
keyTableSizeMb: rawReply[27],
recordsPerDocAvg: rawReply[29],
bytesPerRecordAvg: rawReply[31],
offsetsPerTermAvg: rawReply[33],
offsetBitsPerRecordAvg: rawReply[35],
hashIndexingFailures: rawReply[37],
indexing: rawReply[39],
percentIndexed: rawReply[41],
vectorIndexSzMb: rawReply[19],
totalInvertedIndexBlocks: rawReply[21],
offsetVectorsSzMb: rawReply[23],
docTableSizeMb: rawReply[25],
sortableValuesSizeMb: rawReply[27],
keyTableSizeMb: rawReply[29],
recordsPerDocAvg: rawReply[31],
bytesPerRecordAvg: rawReply[33],
offsetsPerTermAvg: rawReply[35],
offsetBitsPerRecordAvg: rawReply[37],
hashIndexingFailures: rawReply[39],
indexing: rawReply[41],
percentIndexed: rawReply[43],
gcStats: {
bytesCollected: rawReply[43][1],
totalMsRun: rawReply[43][3],
totalCycles: rawReply[43][5],
averageCycleTimeMs: rawReply[43][7],
lastRunTimeMs: rawReply[43][9],
gcNumericTreesMissed: rawReply[43][11],
gcBlocksDenied: rawReply[43][13]
bytesCollected: rawReply[45][1],
totalMsRun: rawReply[45][3],
totalCycles: rawReply[45][5],
averageCycleTimeMs: rawReply[45][7],
lastRunTimeMs: rawReply[45][9],
gcNumericTreesMissed: rawReply[45][11],
gcBlocksDenied: rawReply[45][13]
},
cursorStats: {
globalIdle: rawReply[45][1],
globalTotal: rawReply[45][3],
indexCapacity: rawReply[45][5],
idnexTotal: rawReply[45][7]
}
globalIdle: rawReply[47][1],
globalTotal: rawReply[47][3],
indexCapacity: rawReply[47][5],
idnexTotal: rawReply[47][7]
},
stopWords: rawReply[49]
};
}
exports.transformReply = transformReply;
import { SearchOptions, SearchRawReply } from './SEARCH';
import { ProfileOptions, ProfileRawReply, ProfileReply } from '.';
import { RedisCommandArguments } from '@node-redis/client/dist/lib/commands';
export declare const IS_READ_ONLY = true;
export declare function transformArguments(index: string, query: string, options?: ProfileOptions & SearchOptions): Array<string>;
export declare function transformArguments(index: string, query: string, options?: ProfileOptions & SearchOptions): RedisCommandArguments;
declare type ProfileSearchRawReply = ProfileRawReply<SearchRawReply>;
export declare function transformReply(reply: ProfileSearchRawReply): ProfileReply;
export {};

@@ -13,4 +13,3 @@ "use strict";

args.push('QUERY', query);
(0, _1.pushSearchOptions)(args, options);
return args;
return (0, _1.pushSearchOptions)(args, options);
}

@@ -17,0 +16,0 @@ exports.transformArguments = transformArguments;

import { RedisCommandArguments } from '@node-redis/client/dist/lib/commands';
import { RedisSearchLanguages, PropertyName, SortByProperty, SearchReply } from '.';
import { RedisSearchLanguages, Params, PropertyName, SortByProperty, SearchReply } from '.';
export declare const FIRST_KEY_INDEX = 1;

@@ -35,2 +35,4 @@ export declare const IS_READ_ONLY = true;

};
PARAMS?: Params;
DIALECT?: number;
}

@@ -37,0 +39,0 @@ export declare function transformArguments(index: string, query: string, options?: SearchOptions): RedisCommandArguments;

@@ -9,5 +9,3 @@ "use strict";

function transformArguments(index, query, options) {
const args = ['FT.SEARCH', index, query];
(0, _1.pushSearchOptions)(args, options);
return args;
return (0, _1.pushSearchOptions)(['FT.SEARCH', index, query], options);
}

@@ -14,0 +12,0 @@ exports.transformArguments = transformArguments;

@@ -8,2 +8,3 @@ interface SpellCheckTerms {

TERMS?: SpellCheckTerms | Array<SpellCheckTerms>;
DIALECT?: number;
}

@@ -10,0 +11,0 @@ export declare function transformArguments(index: string, query: string, options?: SpellCheckOptions): Array<string>;

@@ -19,2 +19,5 @@ "use strict";

}
if (options === null || options === void 0 ? void 0 : options.DIALECT) {
args.push('DIALECT', options.DIALECT.toString());
}
return args;

@@ -21,0 +24,0 @@ }

export { default } from './commands';
export { RediSearchSchema, SchemaFieldTypes, SchemaTextFieldPhonetics, SearchReply } from './commands';
export { RediSearchSchema, SchemaFieldTypes, SchemaTextFieldPhonetics, SearchReply, VectorAlgorithms } from './commands';
export { AggregateSteps, AggregateGroupByReducers } from './commands/AGGREGATE';
export { SearchOptions } from './commands/SEARCH';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AggregateGroupByReducers = exports.AggregateSteps = exports.SchemaTextFieldPhonetics = exports.SchemaFieldTypes = exports.default = void 0;
exports.AggregateGroupByReducers = exports.AggregateSteps = exports.VectorAlgorithms = exports.SchemaTextFieldPhonetics = exports.SchemaFieldTypes = exports.default = void 0;
var commands_1 = require("./commands");

@@ -9,4 +9,5 @@ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return commands_1.default; } });

Object.defineProperty(exports, "SchemaTextFieldPhonetics", { enumerable: true, get: function () { return commands_2.SchemaTextFieldPhonetics; } });
Object.defineProperty(exports, "VectorAlgorithms", { enumerable: true, get: function () { return commands_2.VectorAlgorithms; } });
var AGGREGATE_1 = require("./commands/AGGREGATE");
Object.defineProperty(exports, "AggregateSteps", { enumerable: true, get: function () { return AGGREGATE_1.AggregateSteps; } });
Object.defineProperty(exports, "AggregateGroupByReducers", { enumerable: true, get: function () { return AGGREGATE_1.AggregateGroupByReducers; } });
{
"name": "@node-redis/search",
"version": "1.0.4",
"version": "1.0.5",
"license": "MIT",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc