index.d.ts 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. import * as _LIST from './_LIST';
  2. import * as ALTER from './ALTER';
  3. import * as AGGREGATE_WITHCURSOR from './AGGREGATE_WITHCURSOR';
  4. import * as AGGREGATE from './AGGREGATE';
  5. import * as ALIASADD from './ALIASADD';
  6. import * as ALIASDEL from './ALIASDEL';
  7. import * as ALIASUPDATE from './ALIASUPDATE';
  8. import * as CONFIG_GET from './CONFIG_GET';
  9. import * as CONFIG_SET from './CONFIG_SET';
  10. import * as CREATE from './CREATE';
  11. import * as CURSOR_DEL from './CURSOR_DEL';
  12. import * as CURSOR_READ from './CURSOR_READ';
  13. import * as DICTADD from './DICTADD';
  14. import * as DICTDEL from './DICTDEL';
  15. import * as DICTDUMP from './DICTDUMP';
  16. import * as DROPINDEX from './DROPINDEX';
  17. import * as EXPLAIN from './EXPLAIN';
  18. import * as EXPLAINCLI from './EXPLAINCLI';
  19. import * as INFO from './INFO';
  20. import * as PROFILESEARCH from './PROFILE_SEARCH';
  21. import * as PROFILEAGGREGATE from './PROFILE_AGGREGATE';
  22. import * as SEARCH from './SEARCH';
  23. import * as SEARCH_NOCONTENT from './SEARCH_NOCONTENT';
  24. import * as SPELLCHECK from './SPELLCHECK';
  25. import * as SUGADD from './SUGADD';
  26. import * as SUGDEL from './SUGDEL';
  27. import * as SUGGET_WITHPAYLOADS from './SUGGET_WITHPAYLOADS';
  28. import * as SUGGET_WITHSCORES_WITHPAYLOADS from './SUGGET_WITHSCORES_WITHPAYLOADS';
  29. import * as SUGGET_WITHSCORES from './SUGGET_WITHSCORES';
  30. import * as SUGGET from './SUGGET';
  31. import * as SUGLEN from './SUGLEN';
  32. import * as SYNDUMP from './SYNDUMP';
  33. import * as SYNUPDATE from './SYNUPDATE';
  34. import * as TAGVALS from './TAGVALS';
  35. import { RedisCommandArgument, RedisCommandArguments } from '@redis/client/dist/lib/commands';
  36. import { SearchOptions } from './SEARCH';
  37. declare const _default: {
  38. _LIST: typeof _LIST;
  39. _list: typeof _LIST;
  40. ALTER: typeof ALTER;
  41. alter: typeof ALTER;
  42. AGGREGATE_WITHCURSOR: typeof AGGREGATE_WITHCURSOR;
  43. aggregateWithCursor: typeof AGGREGATE_WITHCURSOR;
  44. AGGREGATE: typeof AGGREGATE;
  45. aggregate: typeof AGGREGATE;
  46. ALIASADD: typeof ALIASADD;
  47. aliasAdd: typeof ALIASADD;
  48. ALIASDEL: typeof ALIASDEL;
  49. aliasDel: typeof ALIASDEL;
  50. ALIASUPDATE: typeof ALIASUPDATE;
  51. aliasUpdate: typeof ALIASUPDATE;
  52. CONFIG_GET: typeof CONFIG_GET;
  53. configGet: typeof CONFIG_GET;
  54. CONFIG_SET: typeof CONFIG_SET;
  55. configSet: typeof CONFIG_SET;
  56. CREATE: typeof CREATE;
  57. create: typeof CREATE;
  58. CURSOR_DEL: typeof CURSOR_DEL;
  59. cursorDel: typeof CURSOR_DEL;
  60. CURSOR_READ: typeof CURSOR_READ;
  61. cursorRead: typeof CURSOR_READ;
  62. DICTADD: typeof DICTADD;
  63. dictAdd: typeof DICTADD;
  64. DICTDEL: typeof DICTDEL;
  65. dictDel: typeof DICTDEL;
  66. DICTDUMP: typeof DICTDUMP;
  67. dictDump: typeof DICTDUMP;
  68. DROPINDEX: typeof DROPINDEX;
  69. dropIndex: typeof DROPINDEX;
  70. EXPLAIN: typeof EXPLAIN;
  71. explain: typeof EXPLAIN;
  72. EXPLAINCLI: typeof EXPLAINCLI;
  73. explainCli: typeof EXPLAINCLI;
  74. INFO: typeof INFO;
  75. info: typeof INFO;
  76. PROFILESEARCH: typeof PROFILESEARCH;
  77. profileSearch: typeof PROFILESEARCH;
  78. PROFILEAGGREGATE: typeof PROFILEAGGREGATE;
  79. profileAggregate: typeof PROFILEAGGREGATE;
  80. SEARCH: typeof SEARCH;
  81. search: typeof SEARCH;
  82. SEARCH_NOCONTENT: typeof SEARCH_NOCONTENT;
  83. searchNoContent: typeof SEARCH_NOCONTENT;
  84. SPELLCHECK: typeof SPELLCHECK;
  85. spellCheck: typeof SPELLCHECK;
  86. SUGADD: typeof SUGADD;
  87. sugAdd: typeof SUGADD;
  88. SUGDEL: typeof SUGDEL;
  89. sugDel: typeof SUGDEL;
  90. SUGGET_WITHPAYLOADS: typeof SUGGET_WITHPAYLOADS;
  91. sugGetWithPayloads: typeof SUGGET_WITHPAYLOADS;
  92. SUGGET_WITHSCORES_WITHPAYLOADS: typeof SUGGET_WITHSCORES_WITHPAYLOADS;
  93. sugGetWithScoresWithPayloads: typeof SUGGET_WITHSCORES_WITHPAYLOADS;
  94. SUGGET_WITHSCORES: typeof SUGGET_WITHSCORES;
  95. sugGetWithScores: typeof SUGGET_WITHSCORES;
  96. SUGGET: typeof SUGGET;
  97. sugGet: typeof SUGGET;
  98. SUGLEN: typeof SUGLEN;
  99. sugLen: typeof SUGLEN;
  100. SYNDUMP: typeof SYNDUMP;
  101. synDump: typeof SYNDUMP;
  102. SYNUPDATE: typeof SYNUPDATE;
  103. synUpdate: typeof SYNUPDATE;
  104. TAGVALS: typeof TAGVALS;
  105. tagVals: typeof TAGVALS;
  106. };
  107. export default _default;
  108. export declare enum RedisSearchLanguages {
  109. ARABIC = "Arabic",
  110. BASQUE = "Basque",
  111. CATALANA = "Catalan",
  112. DANISH = "Danish",
  113. DUTCH = "Dutch",
  114. ENGLISH = "English",
  115. FINNISH = "Finnish",
  116. FRENCH = "French",
  117. GERMAN = "German",
  118. GREEK = "Greek",
  119. HUNGARIAN = "Hungarian",
  120. INDONESAIN = "Indonesian",
  121. IRISH = "Irish",
  122. ITALIAN = "Italian",
  123. LITHUANIAN = "Lithuanian",
  124. NEPALI = "Nepali",
  125. NORWEIGAN = "Norwegian",
  126. PORTUGUESE = "Portuguese",
  127. ROMANIAN = "Romanian",
  128. RUSSIAN = "Russian",
  129. SPANISH = "Spanish",
  130. SWEDISH = "Swedish",
  131. TAMIL = "Tamil",
  132. TURKISH = "Turkish",
  133. CHINESE = "Chinese"
  134. }
  135. export type PropertyName = `${'@' | '$.'}${string}`;
  136. export type SortByProperty = string | {
  137. BY: string;
  138. DIRECTION?: 'ASC' | 'DESC';
  139. };
  140. export declare function pushSortByProperty(args: RedisCommandArguments, sortBy: SortByProperty): void;
  141. export declare function pushSortByArguments(args: RedisCommandArguments, name: string, sortBy: SortByProperty | Array<SortByProperty>): RedisCommandArguments;
  142. export declare function pushArgumentsWithLength(args: RedisCommandArguments, fn: (args: RedisCommandArguments) => void): RedisCommandArguments;
  143. export declare enum SchemaFieldTypes {
  144. TEXT = "TEXT",
  145. NUMERIC = "NUMERIC",
  146. GEO = "GEO",
  147. TAG = "TAG",
  148. VECTOR = "VECTOR",
  149. GEOSHAPE = "GEOSHAPE"
  150. }
  151. type CreateSchemaField<T extends SchemaFieldTypes, E = Record<PropertyKey, unknown>> = T | ({
  152. type: T;
  153. AS?: string;
  154. INDEXMISSING?: boolean;
  155. } & E);
  156. type CommonFieldArguments = {
  157. SORTABLE?: boolean | 'UNF';
  158. NOINDEX?: boolean;
  159. };
  160. type CreateSchemaCommonField<T extends SchemaFieldTypes, E = Record<PropertyKey, unknown>> = CreateSchemaField<T, (CommonFieldArguments & E)>;
  161. export declare enum SchemaTextFieldPhonetics {
  162. DM_EN = "dm:en",
  163. DM_FR = "dm:fr",
  164. FM_PT = "dm:pt",
  165. DM_ES = "dm:es"
  166. }
  167. type CreateSchemaTextField = CreateSchemaCommonField<SchemaFieldTypes.TEXT, {
  168. NOSTEM?: true;
  169. WEIGHT?: number;
  170. PHONETIC?: SchemaTextFieldPhonetics;
  171. WITHSUFFIXTRIE?: boolean;
  172. INDEXEMPTY?: boolean;
  173. }>;
  174. type CreateSchemaNumericField = CreateSchemaCommonField<SchemaFieldTypes.NUMERIC>;
  175. type CreateSchemaGeoField = CreateSchemaCommonField<SchemaFieldTypes.GEO>;
  176. type CreateSchemaTagField = CreateSchemaCommonField<SchemaFieldTypes.TAG, {
  177. SEPARATOR?: string;
  178. CASESENSITIVE?: true;
  179. WITHSUFFIXTRIE?: boolean;
  180. INDEXEMPTY?: boolean;
  181. }>;
  182. export declare enum VectorAlgorithms {
  183. FLAT = "FLAT",
  184. HNSW = "HNSW"
  185. }
  186. type CreateSchemaVectorField<T extends VectorAlgorithms, A extends Record<string, unknown>> = CreateSchemaField<SchemaFieldTypes.VECTOR, {
  187. ALGORITHM: T;
  188. TYPE: string;
  189. DIM: number;
  190. DISTANCE_METRIC: 'L2' | 'IP' | 'COSINE';
  191. INITIAL_CAP?: number;
  192. } & A>;
  193. type CreateSchemaFlatVectorField = CreateSchemaVectorField<VectorAlgorithms.FLAT, {
  194. BLOCK_SIZE?: number;
  195. }>;
  196. type CreateSchemaHNSWVectorField = CreateSchemaVectorField<VectorAlgorithms.HNSW, {
  197. M?: number;
  198. EF_CONSTRUCTION?: number;
  199. EF_RUNTIME?: number;
  200. }>;
  201. export declare const SCHEMA_GEO_SHAPE_COORD_SYSTEM: {
  202. readonly SPHERICAL: "SPHERICAL";
  203. readonly FLAT: "FLAT";
  204. };
  205. export type SchemaGeoShapeFieldCoordSystem = typeof SCHEMA_GEO_SHAPE_COORD_SYSTEM[keyof typeof SCHEMA_GEO_SHAPE_COORD_SYSTEM];
  206. type CreateSchemaGeoShapeField = CreateSchemaCommonField<SchemaFieldTypes.GEOSHAPE, {
  207. COORD_SYSTEM?: SchemaGeoShapeFieldCoordSystem;
  208. }>;
  209. export interface RediSearchSchema {
  210. [field: string]: CreateSchemaTextField | CreateSchemaNumericField | CreateSchemaGeoField | CreateSchemaTagField | CreateSchemaFlatVectorField | CreateSchemaHNSWVectorField | CreateSchemaGeoShapeField;
  211. }
  212. export declare function pushSchema(args: RedisCommandArguments, schema: RediSearchSchema): void;
  213. export type Params = Record<string, RedisCommandArgument | number>;
  214. export declare function pushParamsArgs(args: RedisCommandArguments, params?: Params): RedisCommandArguments;
  215. export declare function pushSearchOptions(args: RedisCommandArguments, options?: SearchOptions): RedisCommandArguments;
  216. interface SearchDocumentValue {
  217. [key: string]: string | number | null | Array<SearchDocumentValue> | SearchDocumentValue;
  218. }
  219. export interface SearchReply {
  220. total: number;
  221. documents: Array<{
  222. id: string;
  223. value: SearchDocumentValue;
  224. }>;
  225. }
  226. export interface ProfileOptions {
  227. LIMITED?: true;
  228. }
  229. export type ProfileRawReply<T> = [
  230. results: T,
  231. profile: [
  232. _: string,
  233. TotalProfileTime: string,
  234. _: string,
  235. ParsingTime: string,
  236. _: string,
  237. PipelineCreationTime: string,
  238. _: string,
  239. IteratorsProfile: Array<any>
  240. ]
  241. ];
  242. export interface ProfileReply {
  243. results: SearchReply | AGGREGATE.AggregateReply;
  244. profile: ProfileData;
  245. }
  246. interface ChildIterator {
  247. type?: string;
  248. counter?: number;
  249. term?: string;
  250. size?: number;
  251. time?: string;
  252. childIterators?: Array<ChildIterator>;
  253. }
  254. interface IteratorsProfile {
  255. type?: string;
  256. counter?: number;
  257. queryType?: string;
  258. time?: string;
  259. childIterators?: Array<ChildIterator>;
  260. }
  261. interface ProfileData {
  262. totalProfileTime: string;
  263. parsingTime: string;
  264. pipelineCreationTime: string;
  265. iteratorsProfile: IteratorsProfile;
  266. }
  267. export declare function transformProfile(reply: Array<any>): ProfileData;