index.d.ts 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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. }
  150. type CreateSchemaField<T extends SchemaFieldTypes, E = Record<PropertyKey, unknown>> = T | ({
  151. type: T;
  152. AS?: string;
  153. } & E);
  154. type CreateSchemaCommonField<T extends SchemaFieldTypes, E = Record<PropertyKey, unknown>> = CreateSchemaField<T, ({
  155. SORTABLE?: true | 'UNF';
  156. NOINDEX?: true;
  157. } & E)>;
  158. export declare enum SchemaTextFieldPhonetics {
  159. DM_EN = "dm:en",
  160. DM_FR = "dm:fr",
  161. FM_PT = "dm:pt",
  162. DM_ES = "dm:es"
  163. }
  164. type CreateSchemaTextField = CreateSchemaCommonField<SchemaFieldTypes.TEXT, {
  165. NOSTEM?: true;
  166. WEIGHT?: number;
  167. PHONETIC?: SchemaTextFieldPhonetics;
  168. WITHSUFFIXTRIE?: boolean;
  169. }>;
  170. type CreateSchemaNumericField = CreateSchemaCommonField<SchemaFieldTypes.NUMERIC>;
  171. type CreateSchemaGeoField = CreateSchemaCommonField<SchemaFieldTypes.GEO>;
  172. type CreateSchemaTagField = CreateSchemaCommonField<SchemaFieldTypes.TAG, {
  173. SEPARATOR?: string;
  174. CASESENSITIVE?: true;
  175. WITHSUFFIXTRIE?: boolean;
  176. }>;
  177. export declare enum VectorAlgorithms {
  178. FLAT = "FLAT",
  179. HNSW = "HNSW"
  180. }
  181. type CreateSchemaVectorField<T extends VectorAlgorithms, A extends Record<string, unknown>> = CreateSchemaField<SchemaFieldTypes.VECTOR, {
  182. ALGORITHM: T;
  183. TYPE: string;
  184. DIM: number;
  185. DISTANCE_METRIC: 'L2' | 'IP' | 'COSINE';
  186. INITIAL_CAP?: number;
  187. } & A>;
  188. type CreateSchemaFlatVectorField = CreateSchemaVectorField<VectorAlgorithms.FLAT, {
  189. BLOCK_SIZE?: number;
  190. }>;
  191. type CreateSchemaHNSWVectorField = CreateSchemaVectorField<VectorAlgorithms.HNSW, {
  192. M?: number;
  193. EF_CONSTRUCTION?: number;
  194. EF_RUNTIME?: number;
  195. }>;
  196. export interface RediSearchSchema {
  197. [field: string]: CreateSchemaTextField | CreateSchemaNumericField | CreateSchemaGeoField | CreateSchemaTagField | CreateSchemaFlatVectorField | CreateSchemaHNSWVectorField;
  198. }
  199. export declare function pushSchema(args: RedisCommandArguments, schema: RediSearchSchema): void;
  200. export type Params = Record<string, RedisCommandArgument | number>;
  201. export declare function pushParamsArgs(args: RedisCommandArguments, params?: Params): RedisCommandArguments;
  202. export declare function pushSearchOptions(args: RedisCommandArguments, options?: SearchOptions): RedisCommandArguments;
  203. interface SearchDocumentValue {
  204. [key: string]: string | number | null | Array<SearchDocumentValue> | SearchDocumentValue;
  205. }
  206. export interface SearchReply {
  207. total: number;
  208. documents: Array<{
  209. id: string;
  210. value: SearchDocumentValue;
  211. }>;
  212. }
  213. export interface ProfileOptions {
  214. LIMITED?: true;
  215. }
  216. export type ProfileRawReply<T> = [
  217. results: T,
  218. profile: [
  219. _: string,
  220. TotalProfileTime: string,
  221. _: string,
  222. ParsingTime: string,
  223. _: string,
  224. PipelineCreationTime: string,
  225. _: string,
  226. IteratorsProfile: Array<any>
  227. ]
  228. ];
  229. export interface ProfileReply {
  230. results: SearchReply | AGGREGATE.AggregateReply;
  231. profile: ProfileData;
  232. }
  233. interface ChildIterator {
  234. type?: string;
  235. counter?: number;
  236. term?: string;
  237. size?: number;
  238. time?: string;
  239. childIterators?: Array<ChildIterator>;
  240. }
  241. interface IteratorsProfile {
  242. type?: string;
  243. counter?: number;
  244. queryType?: string;
  245. time?: string;
  246. childIterators?: Array<ChildIterator>;
  247. }
  248. interface ProfileData {
  249. totalProfileTime: string;
  250. parsingTime: string;
  251. pipelineCreationTime: string;
  252. iteratorsProfile: IteratorsProfile;
  253. }
  254. export declare function transformProfile(reply: Array<any>): ProfileData;