@node-redis/search
Advanced tools
Comparing version 1.0.0 to 1.0.1
import { RedisCommandArguments } from '@node-redis/client/dist/lib/commands'; | ||
import { TuplesObject } from '@node-redis/client/dist/lib/commands/generic-transformers'; | ||
import { PropertyName, SortByOptions } from '.'; | ||
import { AggregateReply, PropertyName, SortByProperty } from '.'; | ||
export declare enum AggregateSteps { | ||
@@ -79,3 +78,3 @@ GROUPBY = "GROUPBY", | ||
interface SortStep extends AggregateStep<AggregateSteps.SORTBY> { | ||
BY: SortByOptions | Array<SortByOptions>; | ||
BY: SortByProperty | Array<SortByProperty>; | ||
MAX?: number; | ||
@@ -98,3 +97,3 @@ } | ||
}; | ||
interface AggregateOptions { | ||
export interface AggregateOptions { | ||
VERBATIM?: true; | ||
@@ -105,11 +104,8 @@ LOAD?: LoadField | Array<LoadField>; | ||
export declare function transformArguments(index: string, query: string, options?: AggregateOptions): RedisCommandArguments; | ||
declare type AggregateRawReply = [ | ||
export declare function pushAggregatehOptions(args: RedisCommandArguments, options?: AggregateOptions): RedisCommandArguments; | ||
export declare type AggregateRawReply = [ | ||
total: number, | ||
...results: Array<Array<string>> | ||
]; | ||
interface AggregateReply { | ||
total: number; | ||
results: Array<TuplesObject>; | ||
} | ||
export declare function transformReply(rawReply: AggregateRawReply): AggregateReply; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.transformReply = exports.transformArguments = exports.AggregateGroupByReducers = exports.AggregateSteps = void 0; | ||
exports.transformReply = exports.pushAggregatehOptions = exports.transformArguments = exports.AggregateGroupByReducers = exports.AggregateSteps = void 0; | ||
const generic_transformers_1 = require("@node-redis/client/dist/lib/commands/generic-transformers"); | ||
@@ -32,2 +32,7 @@ const _1 = require("."); | ||
const args = ['FT.AGGREGATE', index, query]; | ||
pushAggregatehOptions(args, options); | ||
return args; | ||
} | ||
exports.transformArguments = transformArguments; | ||
function pushAggregatehOptions(args, options) { | ||
if (options === null || options === void 0 ? void 0 : options.VERBATIM) { | ||
@@ -89,3 +94,3 @@ args.push('VERBATIM'); | ||
} | ||
exports.transformArguments = transformArguments; | ||
exports.pushAggregatehOptions = pushAggregatehOptions; | ||
function pushLoadField(args, toLoad) { | ||
@@ -92,0 +97,0 @@ if (typeof toLoad === 'string') { |
@@ -1,34 +0,2 @@ | ||
import { RedisSearchLanguages, PropertyName } from '.'; | ||
export declare enum SchemaFieldTypes { | ||
TEXT = "TEXT", | ||
NUMERIC = "NUMERIC", | ||
GEO = "GEO", | ||
TAG = "TAG" | ||
} | ||
declare type CreateSchemaField<T extends SchemaFieldTypes, E = Record<string, never>> = T | ({ | ||
type: T; | ||
AS?: string; | ||
SORTABLE?: true | 'UNF'; | ||
NOINDEX?: true; | ||
} & E); | ||
export declare enum SchemaTextFieldPhonetics { | ||
DM_EN = "dm:en", | ||
DM_FR = "dm:fr", | ||
FM_PT = "dm:pt", | ||
DM_ES = "dm:es" | ||
} | ||
declare type CreateSchemaTextField = CreateSchemaField<SchemaFieldTypes.TEXT, { | ||
NOSTEM?: true; | ||
WEIGHT?: number; | ||
PHONETIC?: SchemaTextFieldPhonetics; | ||
}>; | ||
declare type CreateSchemaNumericField = CreateSchemaField<SchemaFieldTypes.NUMERIC>; | ||
declare type CreateSchemaGeoField = CreateSchemaField<SchemaFieldTypes.GEO>; | ||
declare type CreateSchemaTagField = CreateSchemaField<SchemaFieldTypes.TAG, { | ||
SEPERATOR?: string; | ||
CASESENSITIVE?: true; | ||
}>; | ||
interface CreateSchema { | ||
[field: string]: CreateSchemaTextField | CreateSchemaNumericField | CreateSchemaGeoField | CreateSchemaTagField; | ||
} | ||
import { RedisSearchLanguages, PropertyName, CreateSchema } from '.'; | ||
interface CreateOptions { | ||
@@ -35,0 +3,0 @@ ON?: 'HASH' | 'JSON'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.transformArguments = exports.SchemaTextFieldPhonetics = exports.SchemaFieldTypes = void 0; | ||
exports.transformArguments = void 0; | ||
const generic_transformers_1 = require("@node-redis/client/dist/lib/commands/generic-transformers"); | ||
var SchemaFieldTypes; | ||
(function (SchemaFieldTypes) { | ||
SchemaFieldTypes["TEXT"] = "TEXT"; | ||
SchemaFieldTypes["NUMERIC"] = "NUMERIC"; | ||
SchemaFieldTypes["GEO"] = "GEO"; | ||
SchemaFieldTypes["TAG"] = "TAG"; | ||
})(SchemaFieldTypes = exports.SchemaFieldTypes || (exports.SchemaFieldTypes = {})); | ||
var SchemaTextFieldPhonetics; | ||
(function (SchemaTextFieldPhonetics) { | ||
SchemaTextFieldPhonetics["DM_EN"] = "dm:en"; | ||
SchemaTextFieldPhonetics["DM_FR"] = "dm:fr"; | ||
SchemaTextFieldPhonetics["FM_PT"] = "dm:pt"; | ||
SchemaTextFieldPhonetics["DM_ES"] = "dm:es"; | ||
})(SchemaTextFieldPhonetics = exports.SchemaTextFieldPhonetics || (exports.SchemaTextFieldPhonetics = {})); | ||
const _1 = require("."); | ||
function transformArguments(index, schema, options) { | ||
@@ -66,48 +53,5 @@ const args = ['FT.CREATE', index]; | ||
args.push('SCHEMA'); | ||
for (const [field, fieldOptions] of Object.entries(schema)) { | ||
args.push(field); | ||
if (typeof fieldOptions === 'string') { | ||
args.push(fieldOptions); | ||
continue; | ||
} | ||
if (fieldOptions.AS) { | ||
args.push('AS', fieldOptions.AS); | ||
} | ||
args.push(fieldOptions.type); | ||
switch (fieldOptions.type) { | ||
case 'TEXT': | ||
if (fieldOptions.NOSTEM) { | ||
args.push('NOSTEM'); | ||
} | ||
if (fieldOptions.WEIGHT) { | ||
args.push('WEIGHT', fieldOptions.WEIGHT.toString()); | ||
} | ||
if (fieldOptions.PHONETIC) { | ||
args.push('PHONETIC', fieldOptions.PHONETIC); | ||
} | ||
break; | ||
// case 'NUMERIC': | ||
// case 'GEO': | ||
// break; | ||
case 'TAG': | ||
if (fieldOptions.SEPERATOR) { | ||
args.push('SEPERATOR', fieldOptions.SEPERATOR); | ||
} | ||
if (fieldOptions.CASESENSITIVE) { | ||
args.push('CASESENSITIVE'); | ||
} | ||
break; | ||
} | ||
if (fieldOptions.SORTABLE) { | ||
args.push('SORTABLE'); | ||
if (fieldOptions.SORTABLE === 'UNF') { | ||
args.push('UNF'); | ||
} | ||
} | ||
if (fieldOptions.NOINDEX) { | ||
args.push('NOINDEX'); | ||
} | ||
} | ||
(0, _1.pushSchema)(args, schema); | ||
return args; | ||
} | ||
exports.transformArguments = transformArguments; |
import * as _LIST from './_LIST'; | ||
import * as ALTER from './ALTER'; | ||
import * as AGGREGATE from './AGGREGATE'; | ||
@@ -16,2 +17,4 @@ import * as ALIASADD from './ALIASADD'; | ||
import * as INFO from './INFO'; | ||
import * as PROFILESEARCH from './PROFILE_SEARCH'; | ||
import * as PROFILEAGGREGATE from './PROFILE_AGGREGATE'; | ||
import * as SEARCH from './SEARCH'; | ||
@@ -30,5 +33,9 @@ import * as SPELLCHECK from './SPELLCHECK'; | ||
import { RedisCommandArguments } from '@node-redis/client/dist/lib/commands'; | ||
import { TuplesObject } from '@node-redis/client/dist/lib/commands/generic-transformers'; | ||
import { SearchOptions } from './SEARCH'; | ||
declare const _default: { | ||
_LIST: typeof _LIST; | ||
_list: typeof _LIST; | ||
ALTER: typeof ALTER; | ||
alter: typeof ALTER; | ||
AGGREGATE: typeof AGGREGATE; | ||
@@ -62,2 +69,6 @@ aggregate: typeof AGGREGATE; | ||
info: typeof INFO; | ||
PROFILESEARCH: typeof PROFILESEARCH; | ||
profileSearch: typeof PROFILESEARCH; | ||
PROFILEAGGREGATE: typeof PROFILEAGGREGATE; | ||
profileAggregate: typeof PROFILEAGGREGATE; | ||
SEARCH: typeof SEARCH; | ||
@@ -117,7 +128,98 @@ search: typeof SEARCH; | ||
export declare type PropertyName = `${'@' | '$.'}${string}`; | ||
export declare type SortByOptions = PropertyName | { | ||
export declare type SortByProperty = PropertyName | { | ||
BY: PropertyName; | ||
DIRECTION?: 'ASC' | 'DESC'; | ||
}; | ||
export declare function pushSortByArguments(args: RedisCommandArguments, name: string, sortBy: SortByOptions | Array<SortByOptions>): RedisCommandArguments; | ||
export declare function pushSortByProperty(args: RedisCommandArguments, sortBy: SortByProperty): void; | ||
export declare function pushSortByArguments(args: RedisCommandArguments, name: string, sortBy: SortByProperty | Array<SortByProperty>): RedisCommandArguments; | ||
export declare function pushArgumentsWithLength(args: RedisCommandArguments, fn: (args: RedisCommandArguments) => void): RedisCommandArguments; | ||
export declare enum SchemaFieldTypes { | ||
TEXT = "TEXT", | ||
NUMERIC = "NUMERIC", | ||
GEO = "GEO", | ||
TAG = "TAG" | ||
} | ||
declare type CreateSchemaField<T extends SchemaFieldTypes, E = Record<string, never>> = T | ({ | ||
type: T; | ||
AS?: string; | ||
SORTABLE?: true | 'UNF'; | ||
NOINDEX?: true; | ||
} & E); | ||
export declare enum SchemaTextFieldPhonetics { | ||
DM_EN = "dm:en", | ||
DM_FR = "dm:fr", | ||
FM_PT = "dm:pt", | ||
DM_ES = "dm:es" | ||
} | ||
declare type CreateSchemaTextField = CreateSchemaField<SchemaFieldTypes.TEXT, { | ||
NOSTEM?: true; | ||
WEIGHT?: number; | ||
PHONETIC?: SchemaTextFieldPhonetics; | ||
}>; | ||
declare type CreateSchemaNumericField = CreateSchemaField<SchemaFieldTypes.NUMERIC>; | ||
declare type CreateSchemaGeoField = CreateSchemaField<SchemaFieldTypes.GEO>; | ||
declare type CreateSchemaTagField = CreateSchemaField<SchemaFieldTypes.TAG, { | ||
SEPERATOR?: string; | ||
CASESENSITIVE?: true; | ||
}>; | ||
export interface CreateSchema { | ||
[field: string]: CreateSchemaTextField | CreateSchemaNumericField | CreateSchemaGeoField | CreateSchemaTagField; | ||
} | ||
export declare function pushSchema(args: RedisCommandArguments, schema: CreateSchema): void; | ||
export declare function pushSearchOptions(args: RedisCommandArguments, options?: SearchOptions): RedisCommandArguments; | ||
interface SearchDocumentValue { | ||
[key: string]: string | number | null | Array<SearchDocumentValue> | SearchDocumentValue; | ||
} | ||
export interface SearchReply { | ||
total: number; | ||
documents: Array<{ | ||
id: string; | ||
value: SearchDocumentValue; | ||
}>; | ||
} | ||
export interface AggregateReply { | ||
total: number; | ||
results: Array<TuplesObject>; | ||
} | ||
export interface ProfileOptions { | ||
LIMITED?: true; | ||
} | ||
export declare type ProfileRawReply<T> = [ | ||
results: T, | ||
profile: [ | ||
_: string, | ||
TotalProfileTime: string, | ||
_: string, | ||
ParsingTime: string, | ||
_: string, | ||
PipelineCreationTime: string, | ||
_: string, | ||
IteratorsProfile: Array<any> | ||
] | ||
]; | ||
export interface ProfileReply { | ||
results: SearchReply | AggregateReply; | ||
profile: ProfileData; | ||
} | ||
interface ChildIterator { | ||
type?: string; | ||
counter?: number; | ||
term?: string; | ||
size?: number; | ||
time?: string; | ||
childIterators?: Array<ChildIterator>; | ||
} | ||
interface IteratorsProfile { | ||
type?: string; | ||
counter?: number; | ||
queryType?: string; | ||
time?: string; | ||
childIterators?: Array<ChildIterator>; | ||
} | ||
interface ProfileData { | ||
totalProfileTime: string; | ||
parsingTime: string; | ||
pipelineCreationTime: string; | ||
iteratorsProfile: IteratorsProfile; | ||
} | ||
export declare function transformProfile(reply: Array<any>): ProfileData; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.pushArgumentsWithLength = exports.pushSortByArguments = exports.RedisSearchLanguages = void 0; | ||
exports.transformProfile = exports.pushSearchOptions = exports.pushSchema = exports.SchemaTextFieldPhonetics = exports.SchemaFieldTypes = exports.pushArgumentsWithLength = exports.pushSortByArguments = exports.pushSortByProperty = exports.RedisSearchLanguages = void 0; | ||
const _LIST = require("./_LIST"); | ||
const ALTER = require("./ALTER"); | ||
const AGGREGATE = require("./AGGREGATE"); | ||
@@ -19,3 +20,4 @@ const ALIASADD = require("./ALIASADD"); | ||
const INFO = require("./INFO"); | ||
// import * as PROFILE from './PROFILE'; | ||
const PROFILESEARCH = require("./PROFILE_SEARCH"); | ||
const PROFILEAGGREGATE = require("./PROFILE_AGGREGATE"); | ||
const SEARCH = require("./SEARCH"); | ||
@@ -33,5 +35,8 @@ const SPELLCHECK = require("./SPELLCHECK"); | ||
const TAGVALS = require("./TAGVALS"); | ||
const generic_transformers_1 = require("@node-redis/client/dist/lib/commands/generic-transformers"); | ||
exports.default = { | ||
_LIST, | ||
_list: _LIST, | ||
ALTER, | ||
alter: ALTER, | ||
AGGREGATE, | ||
@@ -65,4 +70,6 @@ aggregate: AGGREGATE, | ||
info: INFO, | ||
// PROFILE, | ||
// profile: PROFILE, | ||
PROFILESEARCH, | ||
profileSearch: PROFILESEARCH, | ||
PROFILEAGGREGATE, | ||
profileAggregate: PROFILEAGGREGATE, | ||
SEARCH, | ||
@@ -132,2 +139,3 @@ search: SEARCH, | ||
} | ||
exports.pushSortByProperty = pushSortByProperty; | ||
function pushSortByArguments(args, name, sortBy) { | ||
@@ -155,1 +163,202 @@ const lengthBefore = args.push(name, '' // will be overwritten | ||
exports.pushArgumentsWithLength = pushArgumentsWithLength; | ||
var SchemaFieldTypes; | ||
(function (SchemaFieldTypes) { | ||
SchemaFieldTypes["TEXT"] = "TEXT"; | ||
SchemaFieldTypes["NUMERIC"] = "NUMERIC"; | ||
SchemaFieldTypes["GEO"] = "GEO"; | ||
SchemaFieldTypes["TAG"] = "TAG"; | ||
})(SchemaFieldTypes = exports.SchemaFieldTypes || (exports.SchemaFieldTypes = {})); | ||
var SchemaTextFieldPhonetics; | ||
(function (SchemaTextFieldPhonetics) { | ||
SchemaTextFieldPhonetics["DM_EN"] = "dm:en"; | ||
SchemaTextFieldPhonetics["DM_FR"] = "dm:fr"; | ||
SchemaTextFieldPhonetics["FM_PT"] = "dm:pt"; | ||
SchemaTextFieldPhonetics["DM_ES"] = "dm:es"; | ||
})(SchemaTextFieldPhonetics = exports.SchemaTextFieldPhonetics || (exports.SchemaTextFieldPhonetics = {})); | ||
function pushSchema(args, schema) { | ||
for (const [field, fieldOptions] of Object.entries(schema)) { | ||
args.push(field); | ||
if (typeof fieldOptions === 'string') { | ||
args.push(fieldOptions); | ||
continue; | ||
} | ||
if (fieldOptions.AS) { | ||
args.push('AS', fieldOptions.AS); | ||
} | ||
args.push(fieldOptions.type); | ||
switch (fieldOptions.type) { | ||
case 'TEXT': | ||
if (fieldOptions.NOSTEM) { | ||
args.push('NOSTEM'); | ||
} | ||
if (fieldOptions.WEIGHT) { | ||
args.push('WEIGHT', fieldOptions.WEIGHT.toString()); | ||
} | ||
if (fieldOptions.PHONETIC) { | ||
args.push('PHONETIC', fieldOptions.PHONETIC); | ||
} | ||
break; | ||
// case 'NUMERIC': | ||
// case 'GEO': | ||
// break; | ||
case 'TAG': | ||
if (fieldOptions.SEPERATOR) { | ||
args.push('SEPERATOR', fieldOptions.SEPERATOR); | ||
} | ||
if (fieldOptions.CASESENSITIVE) { | ||
args.push('CASESENSITIVE'); | ||
} | ||
break; | ||
} | ||
if (fieldOptions.SORTABLE) { | ||
args.push('SORTABLE'); | ||
if (fieldOptions.SORTABLE === 'UNF') { | ||
args.push('UNF'); | ||
} | ||
} | ||
if (fieldOptions.NOINDEX) { | ||
args.push('NOINDEX'); | ||
} | ||
} | ||
} | ||
exports.pushSchema = pushSchema; | ||
function pushSearchOptions(args, options) { | ||
if (options === null || options === void 0 ? void 0 : options.VERBATIM) { | ||
args.push('VERBATIM'); | ||
} | ||
if (options === null || options === void 0 ? void 0 : options.NOSTOPWORDS) { | ||
args.push('NOSTOPWORDS'); | ||
} | ||
// if (options?.WITHSCORES) { | ||
// args.push('WITHSCORES'); | ||
// } | ||
// if (options?.WITHPAYLOADS) { | ||
// args.push('WITHPAYLOADS'); | ||
// } | ||
(0, generic_transformers_1.pushOptionalVerdictArgument)(args, 'INKEYS', options === null || options === void 0 ? void 0 : options.INKEYS); | ||
(0, generic_transformers_1.pushOptionalVerdictArgument)(args, 'INFIELDS', options === null || options === void 0 ? void 0 : options.INFIELDS); | ||
(0, generic_transformers_1.pushOptionalVerdictArgument)(args, 'RETURN', options === null || options === void 0 ? void 0 : options.RETURN); | ||
if (options === null || options === void 0 ? void 0 : options.SUMMARIZE) { | ||
args.push('SUMMARIZE'); | ||
if (typeof options.SUMMARIZE === 'object') { | ||
if (options.SUMMARIZE.FIELDS) { | ||
args.push('FIELDS'); | ||
(0, generic_transformers_1.pushVerdictArgument)(args, options.SUMMARIZE.FIELDS); | ||
} | ||
if (options.SUMMARIZE.FRAGS) { | ||
args.push('FRAGS', options.SUMMARIZE.FRAGS.toString()); | ||
} | ||
if (options.SUMMARIZE.LEN) { | ||
args.push('LEN', options.SUMMARIZE.LEN.toString()); | ||
} | ||
if (options.SUMMARIZE.SEPARATOR) { | ||
args.push('SEPARATOR', options.SUMMARIZE.SEPARATOR); | ||
} | ||
} | ||
} | ||
if (options === null || options === void 0 ? void 0 : options.HIGHLIGHT) { | ||
args.push('HIGHLIGHT'); | ||
if (typeof options.HIGHLIGHT === 'object') { | ||
if (options.HIGHLIGHT.FIELDS) { | ||
args.push('FIELDS'); | ||
(0, generic_transformers_1.pushVerdictArgument)(args, options.HIGHLIGHT.FIELDS); | ||
} | ||
if (options.HIGHLIGHT.TAGS) { | ||
args.push('TAGS', options.HIGHLIGHT.TAGS.open, options.HIGHLIGHT.TAGS.close); | ||
} | ||
} | ||
} | ||
if (options === null || options === void 0 ? void 0 : options.SLOP) { | ||
args.push('SLOP', options.SLOP.toString()); | ||
} | ||
if (options === null || options === void 0 ? void 0 : options.INORDER) { | ||
args.push('INORDER'); | ||
} | ||
if (options === null || options === void 0 ? void 0 : options.LANGUAGE) { | ||
args.push('LANGUAGE', options.LANGUAGE); | ||
} | ||
if (options === null || options === void 0 ? void 0 : options.EXPANDER) { | ||
args.push('EXPANDER', options.EXPANDER); | ||
} | ||
if (options === null || options === void 0 ? void 0 : options.SCORER) { | ||
args.push('SCORER', options.SCORER); | ||
} | ||
// if (options?.EXPLAINSCORE) { | ||
// args.push('EXPLAINSCORE'); | ||
// } | ||
// if (options?.PAYLOAD) { | ||
// args.push('PAYLOAD', options.PAYLOAD); | ||
// } | ||
if (options === null || options === void 0 ? void 0 : options.SORTBY) { | ||
args.push('SORTBY'); | ||
pushSortByProperty(args, options.SORTBY); | ||
} | ||
// if (options?.MSORTBY) { | ||
// pushSortByArguments(args, 'MSORTBY', options.MSORTBY); | ||
// } | ||
if (options === null || options === void 0 ? void 0 : options.LIMIT) { | ||
args.push('LIMIT', options.LIMIT.from.toString(), options.LIMIT.size.toString()); | ||
} | ||
return args; | ||
} | ||
exports.pushSearchOptions = pushSearchOptions; | ||
function transformProfile(reply) { | ||
return { | ||
totalProfileTime: reply[0][1], | ||
parsingTime: reply[1][1], | ||
pipelineCreationTime: reply[2][1], | ||
iteratorsProfile: transformIterators(reply[3][1]) | ||
}; | ||
} | ||
exports.transformProfile = transformProfile; | ||
function transformIterators(IteratorsProfile) { | ||
var res = {}; | ||
for (let i = 0; i < IteratorsProfile.length; i += 2) { | ||
const value = IteratorsProfile[i + 1]; | ||
switch (IteratorsProfile[i]) { | ||
case 'Type': | ||
res.type = value; | ||
break; | ||
case 'Counter': | ||
res.counter = value; | ||
break; | ||
case 'Time': | ||
res.time = value; | ||
break; | ||
case 'Query type': | ||
res.queryType = value; | ||
break; | ||
case 'Child iterators': | ||
res.childIterators = value.map(transformChildIterators); | ||
break; | ||
} | ||
} | ||
return res; | ||
} | ||
function transformChildIterators(IteratorsProfile) { | ||
var res = {}; | ||
for (let i = 1; i < IteratorsProfile.length; i += 2) { | ||
const value = IteratorsProfile[i + 1]; | ||
switch (IteratorsProfile[i]) { | ||
case 'Type': | ||
res.type = value; | ||
break; | ||
case 'Counter': | ||
res.counter = value; | ||
break; | ||
case 'Time': | ||
res.time = value; | ||
break; | ||
case 'Size': | ||
res.size = value; | ||
break; | ||
case 'Term': | ||
res.term = value; | ||
break; | ||
case 'Child iterators': | ||
res.childIterators = value.map(transformChildIterators); | ||
break; | ||
} | ||
} | ||
return res; | ||
} |
import { RedisCommandArguments } from '@node-redis/client/dist/lib/commands'; | ||
import { RedisSearchLanguages, PropertyName, SortByOptions } from '.'; | ||
import { RedisSearchLanguages, PropertyName, SortByProperty, SearchReply } from '.'; | ||
export declare const FIRST_KEY_INDEX = 1; | ||
export declare const IS_READ_ONLY = true; | ||
interface SearchOptions { | ||
export interface SearchOptions { | ||
VERBATIM?: true; | ||
@@ -30,3 +30,3 @@ NOSTOPWORDS?: true; | ||
SCORER?: string; | ||
MSORTBY?: SortByOptions | Array<SortByOptions>; | ||
SORTBY?: SortByProperty; | ||
LIMIT?: { | ||
@@ -38,13 +38,3 @@ from: number | string; | ||
export declare function transformArguments(index: string, query: string, options?: SearchOptions): RedisCommandArguments; | ||
interface SearchDocumentValue { | ||
[key: string]: string | number | null | Array<SearchDocumentValue> | SearchDocumentValue; | ||
} | ||
interface SearchReply { | ||
total: number; | ||
documents: Array<{ | ||
id: string; | ||
value: SearchDocumentValue; | ||
}>; | ||
} | ||
export declare function transformReply(reply: Array<any>): SearchReply; | ||
export {}; | ||
export declare type SearchRawReply = Array<any>; | ||
export declare function transformReply(reply: SearchRawReply): SearchReply; |
@@ -10,78 +10,3 @@ "use strict"; | ||
const args = ['FT.SEARCH', index, query]; | ||
if (options === null || options === void 0 ? void 0 : options.VERBATIM) { | ||
args.push('VERBATIM'); | ||
} | ||
if (options === null || options === void 0 ? void 0 : options.NOSTOPWORDS) { | ||
args.push('NOSTOPWORDS'); | ||
} | ||
// if (options?.WITHSCORES) { | ||
// args.push('WITHSCORES'); | ||
// } | ||
// if (options?.WITHPAYLOADS) { | ||
// args.push('WITHPAYLOADS'); | ||
// } | ||
(0, generic_transformers_1.pushOptionalVerdictArgument)(args, 'INKEYS', options === null || options === void 0 ? void 0 : options.INKEYS); | ||
(0, generic_transformers_1.pushOptionalVerdictArgument)(args, 'INFIELDS', options === null || options === void 0 ? void 0 : options.INFIELDS); | ||
(0, generic_transformers_1.pushOptionalVerdictArgument)(args, 'RETURN', options === null || options === void 0 ? void 0 : options.RETURN); | ||
if (options === null || options === void 0 ? void 0 : options.SUMMARIZE) { | ||
args.push('SUMMARIZE'); | ||
if (typeof options.SUMMARIZE === 'object') { | ||
if (options.SUMMARIZE.FIELDS) { | ||
args.push('FIELDS'); | ||
(0, generic_transformers_1.pushVerdictArgument)(args, options.SUMMARIZE.FIELDS); | ||
} | ||
if (options.SUMMARIZE.FRAGS) { | ||
args.push('FRAGS', options.SUMMARIZE.FRAGS.toString()); | ||
} | ||
if (options.SUMMARIZE.LEN) { | ||
args.push('LEN', options.SUMMARIZE.LEN.toString()); | ||
} | ||
if (options.SUMMARIZE.SEPARATOR) { | ||
args.push('SEPARATOR', options.SUMMARIZE.SEPARATOR); | ||
} | ||
} | ||
} | ||
if (options === null || options === void 0 ? void 0 : options.HIGHLIGHT) { | ||
args.push('HIGHLIGHT'); | ||
if (typeof options.HIGHLIGHT === 'object') { | ||
if (options.HIGHLIGHT.FIELDS) { | ||
args.push('FIELDS'); | ||
(0, generic_transformers_1.pushVerdictArgument)(args, options.HIGHLIGHT.FIELDS); | ||
} | ||
if (options.HIGHLIGHT.TAGS) { | ||
args.push('TAGS', options.HIGHLIGHT.TAGS.open, options.HIGHLIGHT.TAGS.close); | ||
} | ||
} | ||
} | ||
if (options === null || options === void 0 ? void 0 : options.SLOP) { | ||
args.push('SLOP', options.SLOP.toString()); | ||
} | ||
if (options === null || options === void 0 ? void 0 : options.INORDER) { | ||
args.push('INORDER'); | ||
} | ||
if (options === null || options === void 0 ? void 0 : options.LANGUAGE) { | ||
args.push('LANGUAGE', options.LANGUAGE); | ||
} | ||
if (options === null || options === void 0 ? void 0 : options.EXPANDER) { | ||
args.push('EXPANDER', options.EXPANDER); | ||
} | ||
if (options === null || options === void 0 ? void 0 : options.SCORER) { | ||
args.push('SCORER', options.SCORER); | ||
} | ||
// if (options?.EXPLAINSCORE) { | ||
// args.push('EXPLAINSCORE'); | ||
// } | ||
// if (options?.PAYLOAD) { | ||
// args.push('PAYLOAD', options.PAYLOAD); | ||
// } | ||
// if (options?.SORTBY) { | ||
// args.push('SORTBY'); | ||
// pushSortByArguments(args, options.SORTBY); | ||
// } | ||
if (options === null || options === void 0 ? void 0 : options.MSORTBY) { | ||
(0, _1.pushSortByArguments)(args, 'MSORTBY', options.MSORTBY); | ||
} | ||
if (options === null || options === void 0 ? void 0 : options.LIMIT) { | ||
args.push('LIMIT', options.LIMIT.from.toString(), options.LIMIT.size.toString()); | ||
} | ||
(0, _1.pushSearchOptions)(args, options); | ||
return args; | ||
@@ -88,0 +13,0 @@ } |
export { default } from './commands'; | ||
export { SchemaFieldTypes, SchemaTextFieldPhonetics } from './commands/CREATE'; | ||
export { SchemaFieldTypes, SchemaTextFieldPhonetics } from './commands'; | ||
export { AggregateSteps, AggregateGroupByReducers } from './commands/AGGREGATE'; |
@@ -6,7 +6,7 @@ "use strict"; | ||
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return commands_1.default; } }); | ||
var CREATE_1 = require("./commands/CREATE"); | ||
Object.defineProperty(exports, "SchemaFieldTypes", { enumerable: true, get: function () { return CREATE_1.SchemaFieldTypes; } }); | ||
Object.defineProperty(exports, "SchemaTextFieldPhonetics", { enumerable: true, get: function () { return CREATE_1.SchemaTextFieldPhonetics; } }); | ||
var commands_2 = require("./commands"); | ||
Object.defineProperty(exports, "SchemaFieldTypes", { enumerable: true, get: function () { return commands_2.SchemaFieldTypes; } }); | ||
Object.defineProperty(exports, "SchemaTextFieldPhonetics", { enumerable: true, get: function () { return commands_2.SchemaTextFieldPhonetics; } }); | ||
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.0", | ||
"version": "1.0.1", | ||
"license": "MIT", | ||
@@ -9,3 +9,4 @@ "main": "./dist/index.js", | ||
"test": "nyc -r text-summary -r lcov mocha -r source-map-support/register -r ts-node/register './lib/**/*.spec.ts'", | ||
"build": "tsc" | ||
"build": "tsc", | ||
"documentation": "typedoc" | ||
}, | ||
@@ -16,5 +17,5 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"@istanbuljs/nyc-config-typescript": "^1.0.1", | ||
"@istanbuljs/nyc-config-typescript": "^1.0.2", | ||
"@node-redis/test-utils": "*", | ||
"@types/node": "^16.11.10", | ||
"@types/node": "^16.11.12", | ||
"nyc": "^15.1.0", | ||
@@ -24,4 +25,5 @@ "release-it": "^14.11.8", | ||
"ts-node": "^10.4.0", | ||
"typescript": "^4.5.2" | ||
"typedoc": "^0.22.10", | ||
"typescript": "^4.5.3" | ||
} | ||
} |
No License Found
License(Experimental) License information could not be found
Found 1 instance in 1 package
0
66924
9
66
1654