client-search.d.ts 83 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482
  1. import { AuthModeType } from '@algolia/client-common';
  2. import { ClientTransporterOptions } from '@algolia/client-common';
  3. import { CreateClient } from '@algolia/client-common';
  4. import { Request } from '@algolia/transporter';
  5. import { RequestOptions } from '@algolia/transporter';
  6. import { Transporter } from '@algolia/transporter';
  7. import { WaitablePromise } from '@algolia/client-common';
  8. export declare const addApiKey: (base: SearchClient) => (acl: readonly ApiKeyACLType[], requestOptions?: (AddApiKeyOptions & Pick<RequestOptions, string | number>) | undefined) => Readonly<WaitablePromise<AddApiKeyResponse>>;
  9. export declare type AddApiKeyOptions = {
  10. /**
  11. * A Unix timestamp used to define the expiration date of the API key.
  12. */
  13. readonly validity?: number;
  14. /**
  15. * Specify the maximum number of hits this API key can retrieve in one call.
  16. * This parameter can be used to protect you from attempts at retrieving your entire index contents by massively querying the index.
  17. */
  18. readonly maxHitsPerQuery?: number;
  19. /**
  20. * Specify the maximum number of API calls allowed from an IP address per hour. Each time an API call is performed with this key, a check is performed.
  21. */
  22. readonly maxQueriesPerIPPerHour?: number;
  23. /**
  24. * Specify the list of targeted indices. You can target all indices starting with a prefix or ending with a suffix using the ‘*’ character.
  25. */
  26. readonly indexes?: readonly string[];
  27. /**
  28. * Specify the list of referers. You can target all referers starting with a prefix, ending with a suffix using the ‘*’ character.
  29. */
  30. readonly referers?: readonly string[];
  31. /**
  32. * Specify the list of query parameters. You can force the query parameters for a query using the url string format.
  33. */
  34. readonly queryParameters?: string;
  35. /**
  36. * Specify a description of the API key. Used for informative purposes only. It has impact on the functionality of the API key.
  37. */
  38. readonly description?: string;
  39. };
  40. export declare type AddApiKeyResponse = {
  41. /**
  42. * The returned api key.
  43. */
  44. key: string;
  45. /**
  46. * Date of creation of the api key.
  47. */
  48. createdAt: string;
  49. };
  50. export declare const ApiKeyACLEnum: Readonly<Record<string, ApiKeyACLType>>;
  51. export declare type ApiKeyACLType = 'addObject' | 'analytics' | 'browse' | 'deleteIndex' | 'deleteObject' | 'editSettings' | 'listIndexes' | 'logs' | 'personalization' | 'recommendation' | 'search' | 'seeUnretrievableAttributes' | 'settings' | 'usage';
  52. export declare const assignUserID: (base: SearchClient) => (userID: string, clusterName: string, requestOptions?: RequestOptions | undefined) => Readonly<Promise<AssignUserIDResponse>>;
  53. export declare type AssignUserIDResponse = {
  54. /**
  55. * Date of creation of the userId.
  56. */
  57. createdAt: string;
  58. };
  59. export declare const assignUserIDs: (base: SearchClient) => (userIDs: readonly string[], clusterName: string, requestOptions?: RequestOptions | undefined) => Readonly<Promise<AssignUserIDsResponse>>;
  60. export declare type AssignUserIDsResponse = {
  61. /**
  62. * Date of creation of the userId
  63. */
  64. createdAt: string;
  65. };
  66. export declare type AutomaticFacetFilter = {
  67. /**
  68. * Attribute to filter on. This must match a facet placeholder in the rule’s pattern.
  69. */
  70. readonly facet: string;
  71. /**
  72. * Whether the filter is disjunctive (true) or conjunctive (false).
  73. */
  74. readonly disjunctive?: boolean;
  75. /**
  76. * Score for the filter. Typically used for optional or disjunctive filters.
  77. */
  78. readonly score?: number;
  79. };
  80. export declare const batch: (base: SearchIndex) => (requests: readonly BatchRequest[], requestOptions?: RequestOptions | undefined) => Readonly<WaitablePromise<BatchResponse>>;
  81. export declare const BatchActionEnum: Readonly<Record<string, BatchActionType>>;
  82. export declare type BatchActionType = 'addObject' | 'updateObject' | 'partialUpdateObject' | 'partialUpdateObjectNoCreate' | 'deleteObject' | 'delete' | 'clear';
  83. export declare type BatchRequest = {
  84. /**
  85. * The batch action.
  86. */
  87. readonly action: BatchActionType;
  88. /**
  89. * The body of the given `action`. Note that, bodies difer
  90. * depending of the action.
  91. */
  92. readonly body: Record<string, any>;
  93. };
  94. export declare type BatchResponse = {
  95. /**
  96. * The operation task id. May be used to perform a wait task.
  97. */
  98. taskID: number;
  99. /**
  100. * The object ids created/updated by the batch request.
  101. */
  102. objectIDs: string[];
  103. };
  104. export declare const browseObjects: (base: SearchIndex) => <TObject>(requestOptions?: (SearchOptions & BrowseOptions<TObject> & RequestOptions) | undefined) => Readonly<Promise<void>>;
  105. export declare type BrowseOptions<TObject> = {
  106. /**
  107. * The callback called for each batch of objects.
  108. */
  109. readonly batch?: (batch: ReadonlyArray<TObject & ObjectWithObjectID>) => any;
  110. /**
  111. * The callback called to determine if the browse should stop. By
  112. * default this checks whether there's any more content to get.
  113. */
  114. readonly shouldStop?: (response: BrowseResponse<TObject>) => boolean;
  115. };
  116. export declare type BrowseRequestData = {
  117. /**
  118. * If available, should be used for browsing to the next page.
  119. */
  120. readonly cursor?: string;
  121. /**
  122. * If cursor is not available, should be used for browsing to the next page.
  123. */
  124. readonly page?: number;
  125. };
  126. export declare type BrowseResponse<TObject> = {
  127. /**
  128. * The hits per page.
  129. */
  130. hits: Array<TObject & ObjectWithObjectID>;
  131. /**
  132. * The cursor used for iterate on the next page.
  133. */
  134. cursor?: string;
  135. };
  136. export declare const browseRules: (base: SearchIndex) => (requestOptions?: (SearchRulesOptions & BrowseOptions<Rule> & RequestOptions) | undefined) => Readonly<Promise<void>>;
  137. export declare const browseSynonyms: (base: SearchIndex) => (requestOptions?: (SearchSynonymsOptions & BrowseOptions<Synonym> & RequestOptions) | undefined) => Readonly<Promise<void>>;
  138. export declare const chunkedBatch: (base: SearchIndex) => (bodies: readonly object[], action: BatchActionType, requestOptions?: (RequestOptions & ChunkOptions) | undefined) => Readonly<WaitablePromise<ChunkedBatchResponse>>;
  139. export declare type ChunkedBatchResponse = {
  140. /**
  141. * The operations task ids. May be used to perform a wait task.
  142. */
  143. taskIDs: number[];
  144. /**
  145. * The object ids created/updated/deleted by the multiple requests.
  146. */
  147. objectIDs: string[];
  148. };
  149. export declare type ChunkOptions = {
  150. /**
  151. * The number of objects per batch.
  152. */
  153. readonly batchSize?: number;
  154. };
  155. export declare const clearDictionaryEntries: (base: SearchClient) => (dictionary: DictionaryName, requestOptions?: (RequestOptions & DictionaryEntriesOptions) | undefined) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
  156. export declare const clearObjects: (base: SearchIndex) => (requestOptions?: RequestOptions | undefined) => Readonly<WaitablePromise<DeleteResponse>>;
  157. export declare const clearRules: (base: SearchIndex) => (requestOptions?: (RequestOptions & ClearRulesOptions) | undefined) => Readonly<WaitablePromise<DeleteResponse>>;
  158. export declare type ClearRulesOptions = {
  159. /**
  160. * If the clear rules request should be forward to replicas.
  161. */
  162. readonly forwardToReplicas?: boolean;
  163. };
  164. export declare const clearSynonyms: (base: SearchIndex) => (requestOptions?: (ClearSynonymsOptions & RequestOptions) | undefined) => Readonly<WaitablePromise<DeleteResponse>>;
  165. export declare type ClearSynonymsOptions = {
  166. /**
  167. * If the clear synonyms request should be forward to replicas.
  168. */
  169. readonly forwardToReplicas?: boolean;
  170. };
  171. export declare type Cluster = {
  172. /**
  173. * The cluster name
  174. */
  175. readonly clusterName: string;
  176. /**
  177. * Number of records in the cluster.
  178. */
  179. readonly nbRecords: number;
  180. /**
  181. * Number of users assign to the cluster.
  182. */
  183. readonly nbUserIDs: number;
  184. /**
  185. * Data size taken by all the users assigned to the cluster.
  186. */
  187. readonly dataSize: number;
  188. };
  189. export declare type Condition = {
  190. /**
  191. * Query patterns are expressed as a string with a specific syntax. A pattern is a sequence of tokens.
  192. */
  193. readonly pattern?: string;
  194. /**
  195. * Apply this rule only when the filter matches.
  196. */
  197. readonly filters?: string;
  198. /**
  199. * is | startsWith | endsWith | contains: Whether the pattern must match the beginning or the end of the query string, or both, or none.
  200. */
  201. readonly anchoring?: 'is' | 'startsWith' | 'endsWith' | 'contains';
  202. /**
  203. * Rule context (format: [A-Za-z0-9_-]+). When specified, the rule is contextual and applies only when the same context is specified at query time (using the ruleContexts parameter).
  204. * When absent, the rule is generic and always applies (provided that its other conditions are met, of course).
  205. */
  206. readonly context?: string;
  207. /**
  208. * If set to true, alternatives make the rule to trigger on synonyms, typos and plurals.
  209. * Note that setting ignorePlurals to false overrides this parameter.
  210. */
  211. readonly alternatives?: boolean;
  212. };
  213. export declare type Consequence = {
  214. /**
  215. * Additional search parameters. Any valid search parameter is allowed.
  216. */
  217. readonly params?: ConsequenceParams & Pick<SearchOptions, Exclude<keyof SearchOptions, 'query'>>;
  218. /**
  219. * Objects to promote as hits.
  220. */
  221. readonly promote?: readonly ConsequencePromote[];
  222. /**
  223. * Objects to hide from hits.
  224. */
  225. readonly hide?: ReadonlyArray<{
  226. readonly objectID: string;
  227. }>;
  228. /**
  229. * Whether the Query Rule should promote or not promoted items.
  230. */
  231. readonly filterPromotes?: boolean;
  232. /**
  233. * Custom JSON object that will be appended to the userData array in the response.
  234. * This object is not interpreted by the API. It is limited to 1kB of minified JSON.
  235. */
  236. readonly userData?: any;
  237. };
  238. export declare type ConsequenceParams = {
  239. /**
  240. * When providing a string, it replaces the entire query string.
  241. * When providing an object, it describes incremental edits to be made to the query string (but you can’t do both).
  242. */
  243. readonly query?: ConsequenceQuery | string;
  244. /**
  245. * Names of facets to which automatic filtering must be applied; they must match the facet name of a facet value placeholder in the query pattern.
  246. */
  247. readonly automaticFacetFilters?: readonly AutomaticFacetFilter[] | readonly string[];
  248. /**
  249. * Same syntax as automaticFacetFilters, but the engine treats the filters as optional.
  250. * Behaves like optionalFilters.
  251. */
  252. readonly automaticOptionalFacetFilters?: readonly AutomaticFacetFilter[] | readonly string[];
  253. /**
  254. * Content defining how the search interface should be rendered.
  255. * A default value for this can be set via settings
  256. */
  257. readonly renderingContent?: Settings['renderingContent'];
  258. };
  259. export declare type ConsequencePromote = {
  260. /**
  261. * Unique identifier of the object to promote.
  262. */
  263. readonly objectID: string;
  264. /**
  265. * Promoted rank for the object (zero-based).
  266. */
  267. readonly position: number;
  268. } | {
  269. /**
  270. * List of unique identifiers for the objects to promote.
  271. */
  272. readonly objectIDs: readonly string[];
  273. /**
  274. * Promoted start rank for the objects (zero-based).
  275. */
  276. readonly position: number;
  277. };
  278. export declare type ConsequenceQuery = {
  279. /**
  280. * List of removes.
  281. */
  282. readonly remove?: readonly string[];
  283. /**
  284. * List of edits.
  285. */
  286. readonly edits?: ReadonlyArray<{
  287. /**
  288. * Type of edit.
  289. */
  290. readonly type?: 'remove' | 'replace';
  291. /**
  292. * Text or patterns to remove from the query string.
  293. */
  294. readonly delete?: string;
  295. /**
  296. * Text that should be inserted in place of the removed text inside the query string.
  297. */
  298. readonly insert?: string;
  299. }>;
  300. };
  301. export declare const copyIndex: (base: SearchClient) => (from: string, to: string, requestOptions?: (CopyIndexOptions & RequestOptions) | undefined) => Readonly<WaitablePromise<IndexOperationResponse>>;
  302. export declare type CopyIndexOptions = {
  303. readonly scope?: readonly ScopeType[];
  304. };
  305. export declare const copyRules: (base: SearchClient) => (from: string, to: string, requestOptions?: RequestOptions | undefined) => Readonly<WaitablePromise<IndexOperationResponse>>;
  306. export declare const copySettings: (base: SearchClient) => (from: string, to: string, requestOptions?: RequestOptions | undefined) => Readonly<WaitablePromise<IndexOperationResponse>>;
  307. export declare const copySynonyms: (base: SearchClient) => (from: string, to: string, requestOptions?: RequestOptions | undefined) => Readonly<WaitablePromise<IndexOperationResponse>>;
  308. export declare function createBrowsablePromise<TObject>(options: {
  309. readonly shouldStop: (response: BrowseResponse<TObject>) => boolean;
  310. readonly request: (data: BrowseRequestData) => Readonly<Promise<BrowseResponse<TObject>>>;
  311. } & BrowseOptions<TObject>): Readonly<Promise<void>>;
  312. export declare type CreateIndex = <TMethods extends {
  313. readonly [key: string]: (base: SearchIndex) => (...args: any) => any;
  314. }>(indexName: string, options?: {
  315. readonly methods?: TMethods;
  316. }) => SearchIndex & {
  317. [key in keyof TMethods extends string ? keyof TMethods : never]: ReturnType<TMethods[key]>;
  318. };
  319. export declare function createMissingObjectIDError(): Error;
  320. export declare function createObjectNotFoundError(): Error;
  321. export declare const createSearchClient: CreateClient<SearchClient, SearchClientOptions & ClientTransporterOptions>;
  322. export declare function createValidUntilNotFoundError(): Error;
  323. export declare const customRequest: <TResponse = any>(base: SearchClient) => (request: Request, requestOptions?: RequestOptions | undefined) => Readonly<Promise<TResponse>>;
  324. export declare const deleteApiKey: (base: SearchClient) => (apiKey: string, requestOptions?: RequestOptions | undefined) => Readonly<WaitablePromise<DeleteApiKeyResponse>>;
  325. export declare type DeleteApiKeyResponse = {
  326. /**
  327. * The date when the api key was deleted.
  328. */
  329. deletedAt: string;
  330. };
  331. export declare const deleteBy: (base: SearchIndex) => (filters: DeleteByFiltersOptions, requestOptions?: RequestOptions | undefined) => Readonly<WaitablePromise<DeleteResponse>>;
  332. export declare type DeleteByFiltersOptions = {
  333. /**
  334. * Filter the query with numeric, facet and/or tag filters.
  335. */
  336. readonly filters?: string;
  337. /**
  338. * Filter hits by facet value.
  339. */
  340. readonly facetFilters?: string | readonly string[] | ReadonlyArray<readonly string[] | string>;
  341. /**
  342. * Filter on numeric attributes.
  343. */
  344. readonly numericFilters?: string | readonly string[] | ReadonlyArray<readonly string[] | string>;
  345. /**
  346. * Filter hits by tags. tagFilters is a different way of filtering, which relies on the _tags
  347. * attribute. It uses a simpler syntax than filters. You can use it when you want to do
  348. * simple filtering based on tags.
  349. */
  350. readonly tagFilters?: string | readonly string[] | ReadonlyArray<readonly string[] | string>;
  351. /**
  352. * Search for entries around a central geolocation, enabling a geo search within a circular area.
  353. */
  354. readonly aroundLatLng?: string;
  355. /**
  356. * Search for entries around a given location automatically computed from the requester’s IP address.
  357. */
  358. readonly aroundLatLngViaIP?: boolean;
  359. /**
  360. * Search inside a rectangular area (in geo coordinates).
  361. */
  362. readonly insideBoundingBox?: ReadonlyArray<readonly number[]> | string;
  363. /**
  364. * Search inside a polygon (in geo coordinates).
  365. */
  366. readonly insidePolygon?: ReadonlyArray<readonly number[]>;
  367. };
  368. export declare const deleteDictionaryEntries: (base: SearchClient) => (dictionary: DictionaryName, objectIDs: readonly string[], requestOptions?: (RequestOptions & DictionaryEntriesOptions) | undefined) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
  369. export declare const deleteIndex: (base: SearchIndex) => (requestOptions?: RequestOptions | undefined) => Readonly<WaitablePromise<DeleteResponse>>;
  370. export declare const deleteObject: (base: SearchIndex) => (objectID: string, requestOptions?: RequestOptions | undefined) => Readonly<WaitablePromise<DeleteResponse>>;
  371. export declare const deleteObjects: (base: SearchIndex) => (objectIDs: readonly string[], requestOptions?: (RequestOptions & ChunkOptions) | undefined) => Readonly<WaitablePromise<ChunkedBatchResponse>>;
  372. export declare type DeleteResponse = {
  373. /**
  374. * The operation task id. May be used to perform a wait task.
  375. */
  376. taskID: number;
  377. };
  378. export declare const deleteRule: (base: SearchIndex) => (objectID: string, requestOptions?: RequestOptions | undefined) => Readonly<WaitablePromise<DeleteResponse>>;
  379. export declare const deleteSynonym: (base: SearchIndex) => (objectID: string, requestOptions?: (RequestOptions & DeleteSynonymOptions) | undefined) => Readonly<WaitablePromise<DeleteResponse>>;
  380. export declare type DeleteSynonymOptions = {
  381. /**
  382. * If the delete synonym request should be forward to replicas.
  383. */
  384. readonly forwardToReplicas?: boolean;
  385. };
  386. export declare type DictionaryEntriesOptions = {
  387. /**
  388. * Array of dictionary entries
  389. */
  390. readonly dictionaryEntries: readonly DictionaryEntry[];
  391. };
  392. export declare type DictionaryEntriesResponse = {
  393. /**
  394. * When the given rules got saved.
  395. */
  396. updatedAt: number;
  397. /**
  398. * The operation task id. May be used to perform a wait task.
  399. */
  400. taskID: number;
  401. };
  402. export declare type DictionaryEntry = {
  403. /**
  404. * Unique identifier for the rule (format: [A-Za-z0-9_-]+).
  405. */
  406. readonly objectID: string;
  407. readonly language: string;
  408. readonly word?: string;
  409. readonly words?: readonly string[];
  410. readonly decomposition?: readonly string[];
  411. readonly state?: 'enabled' | 'disabled';
  412. };
  413. export declare type DictionaryName = 'plurals' | 'stopwords' | 'compounds';
  414. export declare type DictionarySettings = {
  415. /**
  416. * Disable the builtin Algolia entries for a type of dictionary per language.
  417. */
  418. readonly disableStandardEntries: RequireAtLeastOne<Record<DictionaryName, Record<string, boolean>>>;
  419. };
  420. export declare const exists: (base: SearchIndex) => (requestOptions?: RequestOptions | undefined) => Readonly<Promise<boolean>>;
  421. export declare type FacetHit = {
  422. /**
  423. * The value of the facet.
  424. */
  425. readonly value: string;
  426. /**
  427. * The highlighted value.
  428. */
  429. readonly highlighted: string;
  430. /**
  431. * The count.
  432. */
  433. readonly count: number;
  434. };
  435. export declare const findAnswers: (base: SearchIndex) => <TObject>(query: string, queryLanguages: readonly string[], requestOptions?: (RequestOptions & FindAnswersOptions) | undefined) => Readonly<Promise<FindAnswersResponse<TObject>>>;
  436. export declare type FindAnswersOptions = {
  437. /**
  438. * Attributes to use for predictions.
  439. * If using the default (["*"]), all attributes are used to find answers.
  440. */
  441. readonly attributesForPrediction?: readonly string[];
  442. /**
  443. * Maximum number of answers to retrieve from the Answers Engine.
  444. * Cannot be greater than 1000.
  445. */
  446. readonly nbHits?: number;
  447. /**
  448. * Threshold for the answers’ confidence score:
  449. * only answers with extracts that score above this threshold are returned.
  450. */
  451. readonly threshold?: number;
  452. /**
  453. * Whether the attribute name in which the answer was found should be returned.
  454. * This option is expensive in processing time.
  455. */
  456. readonly returnExtractAttribute?: boolean;
  457. /**
  458. * Algolia search parameters to use to fetch the hits.
  459. * Can be any search parameter, except:
  460. * - attributesToSnippet
  461. * - hitsPerPage
  462. * - queryType
  463. * - naturalLanguages and associated parameters
  464. * (removeStopWords, ignorePlurals, and removeWordsIfNoResults)
  465. */
  466. readonly searchParameters?: Omit<SearchOptions, 'attributesToSnippet' | 'hitsPerPage' | 'queryType' | 'naturalLanguages' | 'removeStopWords' | 'ignorePlurals' | 'removeWordsIfNoResults'>;
  467. };
  468. export declare type FindAnswersResponse<TObject = {}> = Omit<SearchResponse<TObject>, 'hits'> & {
  469. /**
  470. * The hits returned by the search.
  471. *
  472. * Hits are ordered according to the ranking or sorting of the index being queried.
  473. */
  474. hits: Array<Hit<TObject & {
  475. _answer?: {
  476. extract: string;
  477. score: number;
  478. extractAttribute: string;
  479. };
  480. }>>;
  481. };
  482. export declare const findObject: (base: SearchIndex) => <TObject>(callback: (object: TObject & ObjectWithObjectID) => boolean, requestOptions?: (FindObjectOptions & RequestOptions) | undefined) => Readonly<Promise<FindObjectResponse<TObject>>>;
  483. export declare type FindObjectOptions = {
  484. /**
  485. * If the underlying find object options should paginate
  486. * over a search method.
  487. */
  488. readonly paginate?: boolean;
  489. /**
  490. * The query used by the underlying find object to
  491. * find the object.
  492. */
  493. readonly query?: string;
  494. };
  495. export declare type FindObjectResponse<TObject> = {
  496. /**
  497. * The found object.
  498. */
  499. object: TObject & ObjectWithObjectID;
  500. /**
  501. * The position where the object was found.
  502. */
  503. position: number;
  504. /**
  505. * The page where the object was found.
  506. */
  507. page: number;
  508. };
  509. export declare const generateSecuredApiKey: () => (parentApiKey: string, restrictions: SecuredApiKeyRestrictions) => string;
  510. export declare const getApiKey: (base: SearchClient) => (apiKey: string, requestOptions?: RequestOptions | undefined) => Readonly<Promise<GetApiKeyResponse>>;
  511. export declare type GetApiKeyResponse = {
  512. /**
  513. * The api key value
  514. */
  515. value: string;
  516. /**
  517. * Date of creation (Unix timestamp).
  518. */
  519. createdAt: number;
  520. /**
  521. * List of permissions the key contains.
  522. */
  523. acl: ApiKeyACLType[];
  524. /**
  525. * A Unix timestamp used to define the expiration date of the API key.
  526. */
  527. validity: number;
  528. /**
  529. * Specify the maximum number of hits this API key can retrieve in one call.
  530. * This parameter can be used to protect you from attempts at retrieving your entire index contents by massively querying the index.
  531. */
  532. maxHitsPerQuery?: number;
  533. /**
  534. * Specify the maximum number of API calls allowed from an IP address per hour. Each time an API call is performed with this key, a check is performed.
  535. */
  536. maxQueriesPerIPPerHour?: number;
  537. /**
  538. * Specify the list of targeted indices. You can target all indices starting with a prefix or ending with a suffix using the ‘*’ character.
  539. */
  540. indexes?: string[];
  541. /**
  542. * Specify the list of referers. You can target all referers starting with a prefix, ending with a suffix using the ‘*’ character.
  543. */
  544. referers?: string[];
  545. /**
  546. * IPv4 network allowed to use the generated key.
  547. * This is used for more protection against API key leaking and reuse.
  548. * Note that you can only provide a single source, but you can specify a range of IPs (e.g., 192.168.1.0/24).
  549. */
  550. restrictSources?: string;
  551. /**
  552. * Specify the list of query parameters. You can force the query parameters for a query using the url string format.
  553. */
  554. queryParameters?: string;
  555. /**
  556. * Specify a description of the API key. Used for informative purposes only. It has impact on the functionality of the API key.
  557. */
  558. description?: string;
  559. };
  560. export declare const getAppTask: (base: SearchClient) => (taskID: number, requestOptions?: RequestOptions | undefined) => Readonly<Promise<TaskStatusResponse>>;
  561. export declare const getDictionarySettings: (base: SearchClient) => (requestOptions?: RequestOptions | undefined) => Readonly<Promise<GetDictionarySettingsResponse>>;
  562. export declare type GetDictionarySettingsResponse = {
  563. /**
  564. * Disable the builtin Algolia entries for a type of dictionary per language.
  565. */
  566. readonly disableStandardEntries: RequireAtLeastOne<Record<DictionaryName, Record<string, boolean>>>;
  567. };
  568. export declare const getLogs: (base: SearchClient) => (requestOptions?: RequestOptions | undefined) => Readonly<Promise<GetLogsResponse>>;
  569. export declare type GetLogsOptions = {
  570. /**
  571. * The offset.
  572. */
  573. readonly offset: number;
  574. /**
  575. * The length size.
  576. */
  577. readonly length: number;
  578. };
  579. export declare type GetLogsResponse = {
  580. /**
  581. * The list of logs.
  582. */
  583. logs: Log[];
  584. };
  585. export declare const getObject: (base: SearchIndex) => <TObject>(objectID: string, requestOptions?: (RequestOptions & GetObjectOptions) | undefined) => Readonly<Promise<TObject & ObjectWithObjectID>>;
  586. export declare type GetObjectOptions = {
  587. /**
  588. * The attributes that should come with witch object.
  589. */
  590. readonly attributesToRetrieve?: readonly string[];
  591. };
  592. export declare const getObjectPosition: <TObject>() => (searchResponse: SearchResponse<TObject>, objectID: string) => number;
  593. export declare const getObjects: (base: SearchIndex) => <TObject>(objectIDs: readonly string[], requestOptions?: (RequestOptions & GetObjectsOptions) | undefined) => Readonly<Promise<GetObjectsResponse<TObject>>>;
  594. export declare type GetObjectsOptions = {
  595. /**
  596. * The attributes that should come with witch object.
  597. */
  598. readonly attributesToRetrieve?: readonly string[];
  599. };
  600. export declare type GetObjectsResponse<TObject> = {
  601. /**
  602. * The list of results.
  603. */
  604. results: Array<(TObject & ObjectWithObjectID) | null>;
  605. };
  606. export declare const getRule: (base: SearchIndex) => (objectID: string, requestOptions?: RequestOptions | undefined) => Readonly<Promise<Rule>>;
  607. export declare const getSecuredApiKeyRemainingValidity: () => (securedApiKey: string) => number;
  608. export declare const getSettings: (base: SearchIndex) => (requestOptions?: RequestOptions | undefined) => Readonly<Promise<Settings>>;
  609. export declare const getSynonym: (base: SearchIndex) => (objectID: string, requestOptions?: RequestOptions | undefined) => Readonly<Promise<Synonym>>;
  610. export declare const getTask: (base: SearchIndex) => (taskID: number, requestOptions?: RequestOptions | undefined) => Readonly<Promise<TaskStatusResponse>>;
  611. export declare const getTopUserIDs: (base: SearchClient) => (requestOptions?: RequestOptions | undefined) => Readonly<Promise<GetTopUserIDsResponse>>;
  612. export declare type GetTopUserIDsResponse = {
  613. /**
  614. * Mapping of cluster names to top users.
  615. */
  616. topUsers: Record<string, UserIDResponse[]>;
  617. };
  618. export declare const getUserID: (base: SearchClient) => (userID: string, requestOptions?: RequestOptions | undefined) => Readonly<Promise<UserIDResponse>>;
  619. export declare const hasPendingMappings: (base: SearchClient) => (requestOptions?: (HasPendingMappingsOptions & RequestOptions) | undefined) => Readonly<Promise<HasPendingMappingsResponse>>;
  620. export declare type HasPendingMappingsOptions = {
  621. /**
  622. * If the clusters pending mapping state should be on the response.
  623. *
  624. * @defaultValue false
  625. */
  626. readonly retrieveMappings?: boolean;
  627. /**
  628. * If the clusters pending mapping state should be on the response.
  629. *
  630. * @defaultValue false
  631. *
  632. * @internal
  633. */
  634. readonly getClusters?: boolean;
  635. };
  636. export declare type HasPendingMappingsResponse = {
  637. /**
  638. * If there is any clusters with pending mapping state.
  639. */
  640. pending: boolean;
  641. /**
  642. * Describe cluster pending (migrating, creating, deleting) mapping state.
  643. */
  644. clusters?: {
  645. [key: string]: string[];
  646. };
  647. };
  648. declare type HighlightMatch = {
  649. readonly value: string;
  650. readonly matchLevel: 'none' | 'partial' | 'full';
  651. readonly matchedWords: readonly string[];
  652. readonly fullyHighlighted?: boolean;
  653. };
  654. export declare type HighlightResult<THit> = THit extends string | number ? HighlightMatch : {
  655. [KAttribute in keyof THit]?: HighlightResult<THit[KAttribute]>;
  656. };
  657. export declare type Hit<THit> = THit & {
  658. readonly objectID: string;
  659. readonly _highlightResult?: HighlightResult<THit>;
  660. readonly _snippetResult?: SnippetResult<THit>;
  661. readonly _rankingInfo?: RankingInfo;
  662. readonly _distinctSeqID?: number;
  663. };
  664. export declare type Index = {
  665. /**
  666. * Index name.
  667. */
  668. readonly name: string;
  669. /**
  670. * Index creation date. (ISO-8601 format)
  671. */
  672. readonly createdAt: string;
  673. /**
  674. * Date of last update. (ISO-8601 format)
  675. */
  676. readonly updatedAt: string;
  677. /**
  678. * Number of records contained in the index
  679. */
  680. readonly entries: number;
  681. /**
  682. * Number of bytes of the index in minified format.
  683. */
  684. readonly dataSize: number;
  685. /**
  686. * Number of bytes of the index binary file.
  687. */
  688. readonly fileSize: number;
  689. /**
  690. * Last build time in seconds.
  691. */
  692. readonly lastBuildTimeS: number;
  693. /**
  694. * Number of pending indexing operations.
  695. */
  696. readonly numberOfPendingTasks: number;
  697. /**
  698. * A boolean which says whether the index has pending tasks.
  699. */
  700. readonly pendingTask: boolean;
  701. /**
  702. * Only present if the index is a replica.
  703. * Contains the name of the related primary index.
  704. */
  705. readonly primary?: string;
  706. /**
  707. * Only present if the index is a primary index with replicas.
  708. * Contains the names of all linked replicas.
  709. */
  710. readonly replicas?: readonly string[];
  711. };
  712. export declare type IndexOperationResponse = {
  713. /**
  714. * The operation task id. May be used to perform a wait task.
  715. */
  716. taskID: number;
  717. };
  718. /**
  719. * @deprecated please use `Index` instead of `Indice`
  720. */
  721. export declare type Indice = Index;
  722. export declare const initIndex: (base: SearchClient) => CreateIndex;
  723. export declare const listApiKeys: (base: SearchClient) => (requestOptions?: RequestOptions | undefined) => Readonly<Promise<ListApiKeysResponse>>;
  724. export declare type ListApiKeysResponse = {
  725. /**
  726. * List of keys
  727. */
  728. keys: GetApiKeyResponse[];
  729. };
  730. export declare const listClusters: (base: SearchClient) => (requestOptions?: RequestOptions | undefined) => Readonly<Promise<ListClustersResponse>>;
  731. export declare type ListClustersResponse = {
  732. /**
  733. * List of clusters.
  734. */
  735. clusters: Cluster[];
  736. };
  737. export declare const listIndices: (base: SearchClient) => (requestOptions?: RequestOptions | undefined) => Readonly<Promise<ListIndicesResponse>>;
  738. export declare type ListIndicesResponse = {
  739. /**
  740. * Number of pages
  741. */
  742. nbPages: number;
  743. /**
  744. * List of index response
  745. */
  746. items: Index[];
  747. };
  748. export declare const listUserIDs: (base: SearchClient) => (requestOptions?: (ListUserIDsOptions & RequestOptions) | undefined) => Readonly<Promise<ListUserIDsResponse>>;
  749. export declare type ListUserIDsOptions = {
  750. /**
  751. * Page to fetch.
  752. */
  753. readonly page?: number;
  754. /**
  755. * Number of users to retrieve per page.
  756. */
  757. readonly hitsPerPage?: number;
  758. };
  759. export declare type ListUserIDsResponse = {
  760. /**
  761. * List of users id.
  762. */
  763. userIDs: UserIDResponse[];
  764. };
  765. export declare type Log = {
  766. /**
  767. * Timestamp in ISO-8601 format.
  768. */
  769. readonly timestamp: string;
  770. /**
  771. * Rest type of the method.
  772. */
  773. readonly method: string;
  774. /**
  775. * Http response code.
  776. */
  777. readonly answer_code: string;
  778. /**
  779. * Request body. It’s truncated after 1000 characters.
  780. */
  781. readonly query_body: string;
  782. /**
  783. * Answer body. It’s truncated after 1000 characters.
  784. */
  785. readonly answer: string;
  786. /**
  787. * Request URL.
  788. */
  789. readonly url: string;
  790. /**
  791. * Client ip of the call.
  792. */
  793. readonly ip: string;
  794. /**
  795. * SHA1 ID of entry.
  796. */
  797. readonly sha1: string;
  798. /**
  799. * Request Headers (API Key is obfuscated).
  800. */
  801. readonly query_headers: string;
  802. /**
  803. * Number Of Api Calls
  804. */
  805. readonly nb_api_calls?: string;
  806. /**
  807. * Processing time for the query. This does not include network time.
  808. */
  809. readonly processing_time_ms: string;
  810. /**
  811. * Number of hits returned for the query.
  812. */
  813. readonly query_nb_hits?: string;
  814. /**
  815. * Exhaustive flags used during the query.
  816. */
  817. readonly exhaustive?: boolean;
  818. /**
  819. * Index name of the log
  820. */
  821. readonly index?: string;
  822. /**
  823. * Internal queries performed for this query.
  824. */
  825. readonly inner_queries: ReadonlyArray<{
  826. /**
  827. * Index name of the query.
  828. */
  829. readonly index_name: string;
  830. /**
  831. * Query ID of the query.
  832. */
  833. readonly query_id?: string;
  834. /**
  835. * The offset of the query.
  836. */
  837. readonly offset?: number;
  838. /**
  839. * The user token of the query.
  840. */
  841. readonly user_token?: string;
  842. }>;
  843. };
  844. export declare const moveIndex: (base: SearchClient) => (from: string, to: string, requestOptions?: RequestOptions | undefined) => Readonly<WaitablePromise<IndexOperationResponse>>;
  845. export declare const multipleBatch: (base: SearchClient) => (requests: readonly MultipleBatchRequest[], requestOptions?: RequestOptions | undefined) => Readonly<WaitablePromise<MultipleBatchResponse>>;
  846. export declare type MultipleBatchRequest = {
  847. /**
  848. * The index name where the multiple batch are going to be applied.
  849. */
  850. readonly indexName: string;
  851. /**
  852. * The action used.
  853. */
  854. readonly action: BatchActionType;
  855. /**
  856. * The body associated with the request.
  857. */
  858. readonly body: Record<string, any>;
  859. };
  860. export declare type MultipleBatchResponse = {
  861. /**
  862. * The list of object ids.
  863. */
  864. objectIDs: string[];
  865. /**
  866. * The operation task id. May be used to perform a wait task.
  867. */
  868. taskID: Record<string, number>;
  869. };
  870. export declare type MultipleGetObject = {
  871. /**
  872. * The index name.
  873. */
  874. readonly indexName: string;
  875. /**
  876. * The object id.
  877. */
  878. readonly objectID: string;
  879. /**
  880. * The attributes that should be returned with the object.
  881. */
  882. readonly attributesToRetrieve?: readonly string[];
  883. };
  884. export declare const multipleGetObjects: (base: SearchClient) => <TObject>(requests: readonly MultipleGetObject[], requestOptions?: RequestOptions | undefined) => Readonly<Promise<MultipleGetObjectsResponse<TObject>>>;
  885. export declare type MultipleGetObjectsResponse<TObject> = {
  886. /**
  887. * The list of objects.
  888. */
  889. results: Array<TObject & ObjectWithObjectID>;
  890. };
  891. export declare const multipleQueries: (base: SearchClient) => <TObject>(queries: readonly MultipleQueriesQuery[], requestOptions?: (RequestOptions & MultipleQueriesOptions) | undefined) => Readonly<Promise<MultipleQueriesResponse<TObject>>>;
  892. export declare type MultipleQueriesOptions = {
  893. readonly strategy?: StrategyType;
  894. };
  895. export declare type MultipleQueriesQuery = SharedMultipleQueriesQuery & ({
  896. readonly type?: 'default';
  897. } | {
  898. readonly type: 'facet';
  899. /**
  900. * The facet name.
  901. */
  902. readonly facet: string;
  903. /**
  904. * The search options.
  905. */
  906. readonly params?: SharedMultipleQueriesQuery['params'] & {
  907. /**
  908. * The search query used to search the facet attribute. Follows the same rules for an index query: a single character, a partial word, a word, or a phrase.
  909. */
  910. readonly facetQuery?: string;
  911. };
  912. });
  913. export declare type MultipleQueriesResponse<TObject> = {
  914. /**
  915. * The list of results.
  916. */
  917. results: Array<SearchResponse<TObject>>;
  918. };
  919. export declare const multipleSearchForFacetValues: (base: SearchClient) => (queries: readonly {
  920. readonly indexName: string;
  921. readonly params: SearchForFacetValuesQueryParams & SearchOptions;
  922. }[], requestOptions?: RequestOptions | undefined) => Readonly<Promise<readonly SearchForFacetValuesResponse[]>>;
  923. export declare type ObjectWithObjectID = {
  924. /**
  925. * The object id of the object.
  926. */
  927. readonly objectID: string;
  928. };
  929. export declare const partialUpdateObject: (base: SearchIndex) => (object: Record<string, any>, requestOptions?: (RequestOptions & ChunkOptions & PartialUpdateObjectsOptions) | undefined) => Readonly<WaitablePromise<PartialUpdateObjectResponse>>;
  930. export declare type PartialUpdateObjectResponse = {
  931. /**
  932. * The operation task id. May be used to perform a wait task.
  933. */
  934. taskID: number;
  935. /**
  936. * The object id updated.
  937. */
  938. objectID: string;
  939. };
  940. export declare const partialUpdateObjects: (base: SearchIndex) => (objects: readonly Record<string, any>[], requestOptions?: (RequestOptions & ChunkOptions & PartialUpdateObjectsOptions) | undefined) => Readonly<WaitablePromise<ChunkedBatchResponse>>;
  941. export declare type PartialUpdateObjectsOptions = {
  942. /**
  943. * If the object should be created when does not exist.
  944. */
  945. readonly createIfNotExists?: boolean;
  946. };
  947. export declare type RankingInfo = {
  948. readonly promoted: boolean;
  949. readonly nbTypos: number;
  950. readonly firstMatchedWord: number;
  951. readonly proximityDistance?: number;
  952. readonly geoDistance: number;
  953. readonly geoPrecision?: number;
  954. readonly nbExactWords: number;
  955. readonly words: number;
  956. readonly filters: number;
  957. readonly userScore: number;
  958. readonly matchedGeoLocation?: {
  959. readonly lat: number;
  960. readonly lng: number;
  961. readonly distance: number;
  962. };
  963. readonly personalization?: {
  964. readonly filtersScore: number;
  965. readonly rankingScore: number;
  966. readonly score: number;
  967. };
  968. readonly promotedByReRanking?: boolean;
  969. };
  970. export declare const removeUserID: (base: SearchClient) => (userID: string, requestOptions?: RequestOptions | undefined) => Readonly<Promise<RemoveUserIDResponse>>;
  971. export declare type RemoveUserIDResponse = {
  972. /**
  973. * When the given `userID` got removed.
  974. */
  975. deletedAt: string;
  976. };
  977. export declare const replaceAllObjects: (base: SearchIndex) => (objects: readonly Readonly<Record<string, any>>[], requestOptions?: (ReplaceAllObjectsOptions & ChunkOptions & SaveObjectsOptions & RequestOptions) | undefined) => Readonly<WaitablePromise<ChunkedBatchResponse>>;
  978. export declare type ReplaceAllObjectsOptions = {
  979. /**
  980. * If the all objects should be replaced using wait operations. Keep
  981. * in mind that, when the `safe` option is used, the operation may
  982. * take a little more than expected.
  983. */
  984. readonly safe?: boolean;
  985. };
  986. export declare const replaceAllRules: (base: SearchIndex) => (rules: readonly Rule[], requestOptions?: (RequestOptions & SaveRulesOptions) | undefined) => Readonly<WaitablePromise<SaveRulesResponse>>;
  987. export declare const replaceAllSynonyms: (base: SearchIndex) => (synonyms: readonly Synonym[], requestOptions?: (RequestOptions & Pick<SaveSynonymsOptions, "forwardToReplicas">) | undefined) => Readonly<WaitablePromise<SaveSynonymsResponse>>;
  988. export declare const replaceDictionaryEntries: (base: SearchClient) => (dictionary: DictionaryName, entries: readonly DictionaryEntry[], requestOptions?: (RequestOptions & DictionaryEntriesOptions) | undefined) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
  989. export declare type RequireAtLeastOne<TType> = {
  990. [TKey in keyof TType]-?: Required<Pick<TType, TKey>> & Partial<Pick<TType, Exclude<keyof TType, TKey>>>;
  991. }[keyof TType];
  992. export declare const restoreApiKey: (base: SearchClient) => (apiKey: string, requestOptions?: RequestOptions | undefined) => Readonly<WaitablePromise<RestoreApiKeyResponse>>;
  993. export declare type RestoreApiKeyResponse = {
  994. /**
  995. * Restoration date of the API key.
  996. */
  997. createdAt: string;
  998. };
  999. export declare type Rule = {
  1000. /**
  1001. * Unique identifier for the rule (format: [A-Za-z0-9_-]+).
  1002. */
  1003. readonly objectID: string;
  1004. /**
  1005. * Condition of the rule, expressed using the following variables: pattern, anchoring, context.
  1006. *
  1007. * @deprecated This parameter is deprecated in favor of `conditions`.
  1008. */
  1009. readonly condition?: Condition;
  1010. /**
  1011. * Conditions of the rule, expressed using the following variables: pattern, anchoring, context.
  1012. */
  1013. readonly conditions?: readonly Condition[];
  1014. /**
  1015. * Consequence of the rule. At least one of the following object must be used: params, promote, hide, userData.
  1016. */
  1017. readonly consequence?: Consequence;
  1018. /**
  1019. * This field is intended for rule management purposes, in particular to ease searching for rules and presenting them to human readers. It is not interpreted by the API.
  1020. */
  1021. readonly description?: string;
  1022. /**
  1023. * Whether the rule is enabled. Disabled rules remain in the index, but are not applied at query time.
  1024. */
  1025. readonly enabled?: boolean;
  1026. /**
  1027. * By default, rules are permanently valid. When validity periods are specified, the rule applies only during those periods; it is ignored the rest of the time.
  1028. * The list must not be empty.
  1029. */
  1030. readonly validity?: readonly TimeRange[];
  1031. };
  1032. export declare const saveDictionaryEntries: (base: SearchClient) => (dictionary: DictionaryName, entries: readonly DictionaryEntry[], requestOptions?: (RequestOptions & DictionaryEntriesOptions) | undefined) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
  1033. export declare const saveObject: (base: SearchIndex) => (object: Readonly<Record<string, any>>, requestOptions?: (RequestOptions & ChunkOptions & SaveObjectsOptions) | undefined) => Readonly<WaitablePromise<SaveObjectResponse>>;
  1034. export declare type SaveObjectResponse = {
  1035. /**
  1036. * The operation task id. May be used to perform a wait task.
  1037. */
  1038. taskID: number;
  1039. /**
  1040. * The object id saved.
  1041. */
  1042. objectID: string;
  1043. };
  1044. export declare const saveObjects: (base: SearchIndex) => (objects: readonly Readonly<Record<string, any>>[], requestOptions?: (RequestOptions & ChunkOptions & SaveObjectsOptions) | undefined) => Readonly<WaitablePromise<ChunkedBatchResponse>>;
  1045. export declare type SaveObjectsOptions = {
  1046. /**
  1047. * If the object id should be generated when does not exists.
  1048. */
  1049. readonly autoGenerateObjectIDIfNotExist?: boolean;
  1050. };
  1051. export declare const saveRule: (base: SearchIndex) => (rule: Rule, requestOptions?: (RequestOptions & SaveRulesOptions) | undefined) => Readonly<WaitablePromise<SaveRuleResponse>>;
  1052. export declare type SaveRuleResponse = {
  1053. /**
  1054. * When the given rules got saved.
  1055. */
  1056. updatedAt: number;
  1057. /**
  1058. * The operation task id. May be used to perform a wait task.
  1059. */
  1060. taskID: number;
  1061. };
  1062. export declare const saveRules: (base: SearchIndex) => (rules: readonly Rule[], requestOptions?: (RequestOptions & SaveRulesOptions) | undefined) => Readonly<WaitablePromise<SaveRulesResponse>>;
  1063. export declare type SaveRulesOptions = {
  1064. /**
  1065. * If the saved rules should be forward to replicas.
  1066. */
  1067. readonly forwardToReplicas?: boolean;
  1068. /**
  1069. * If the existing rules should be removed.
  1070. */
  1071. readonly clearExistingRules?: boolean;
  1072. };
  1073. export declare type SaveRulesResponse = {
  1074. /**
  1075. * When the given rules got saved.
  1076. */
  1077. updatedAt: number;
  1078. /**
  1079. * The operation task id. May be used to perform a wait task.
  1080. */
  1081. taskID: number;
  1082. };
  1083. export declare const saveSynonym: (base: SearchIndex) => (synonym: Synonym, requestOptions?: (RequestOptions & SaveSynonymsOptions) | undefined) => Readonly<WaitablePromise<SaveSynonymResponse>>;
  1084. export declare type SaveSynonymResponse = {
  1085. /**
  1086. * When the given synonyms got saved.
  1087. */
  1088. updatedAt: number;
  1089. /**
  1090. * The operation task id. May be used to perform a wait task.
  1091. */
  1092. taskID: number;
  1093. };
  1094. export declare const saveSynonyms: (base: SearchIndex) => (synonyms: readonly Synonym[], requestOptions?: (SaveSynonymsOptions & RequestOptions) | undefined) => Readonly<WaitablePromise<SaveSynonymsResponse>>;
  1095. export declare type SaveSynonymsOptions = {
  1096. /**
  1097. * If the saved synonyms should be forward to replicas.
  1098. */
  1099. readonly forwardToReplicas?: boolean;
  1100. /**
  1101. * If the existing synonyms should be removed.
  1102. * @deprecated use clearExistingSynonyms
  1103. */
  1104. readonly replaceExistingSynonyms?: boolean;
  1105. /**
  1106. * If the existing synonyms should be removed.
  1107. */
  1108. readonly clearExistingSynonyms?: boolean;
  1109. };
  1110. export declare type SaveSynonymsResponse = {
  1111. /**
  1112. * When the given synonyms got saved.
  1113. */
  1114. updatedAt: number;
  1115. /**
  1116. * The operation task id. May be used to perform a wait task.
  1117. */
  1118. taskID: number;
  1119. };
  1120. export declare const ScopeEnum: Readonly<Record<string, ScopeType>>;
  1121. export declare type ScopeType = 'settings' | 'synonyms' | 'rules';
  1122. export declare const search: (base: SearchIndex) => <TObject>(query: string, requestOptions?: (RequestOptions & SearchOptions) | undefined) => Readonly<Promise<SearchResponse<TObject>>>;
  1123. export declare type SearchClient = {
  1124. /**
  1125. * The application id.
  1126. */
  1127. readonly appId: string;
  1128. /**
  1129. * The underlying transporter.
  1130. */
  1131. readonly transporter: Transporter;
  1132. /**
  1133. * Mutates the transporter, adding the given user agent.
  1134. */
  1135. readonly addAlgoliaAgent: (segment: string, version?: string) => void;
  1136. /**
  1137. * Clears both requests and responses caches.
  1138. */
  1139. readonly clearCache: () => Readonly<Promise<void>>;
  1140. };
  1141. export declare type SearchClientOptions = {
  1142. /**
  1143. * The application id.
  1144. */
  1145. readonly appId: string;
  1146. /**
  1147. * The api key.
  1148. */
  1149. readonly apiKey: string;
  1150. /**
  1151. * The auth mode type. In browser environments credentials may
  1152. * be passed within the headers.
  1153. */
  1154. readonly authMode?: AuthModeType;
  1155. };
  1156. export declare const searchDictionaryEntries: (base: SearchClient) => (dictionary: DictionaryName, query: string, requestOptions?: RequestOptions | undefined) => Readonly<Promise<SearchDictionaryEntriesResponse>>;
  1157. export declare type SearchDictionaryEntriesResponse = {
  1158. /**
  1159. * The dictionary entries returned by the search.
  1160. */
  1161. hits: DictionaryEntry[];
  1162. /**
  1163. * Index of the current page (zero-based).
  1164. */
  1165. page: number;
  1166. /**
  1167. * Number of dictionary entries matched by the query.
  1168. */
  1169. nbHits: number;
  1170. /**
  1171. * Number of pages returned.
  1172. *
  1173. * Calculation is based on the total number of hits (nbHits) divided by the
  1174. * number of hits per page (hitsPerPage), rounded up to the nearest integer.
  1175. */
  1176. nbPages: number;
  1177. };
  1178. export declare const searchForFacetValues: (base: SearchIndex) => (facetName: string, facetQuery: string, requestOptions?: (RequestOptions & SearchOptions) | undefined) => Readonly<Promise<SearchForFacetValuesResponse>>;
  1179. export declare type SearchForFacetValuesQueryParams = {
  1180. /**
  1181. * The facet name.
  1182. */
  1183. readonly facetName: string;
  1184. /**
  1185. * The facet query.
  1186. */
  1187. readonly facetQuery: string;
  1188. };
  1189. export declare type SearchForFacetValuesResponse = {
  1190. /**
  1191. * The list of facet hits.
  1192. */
  1193. facetHits: FacetHit[];
  1194. /**
  1195. * The exhaustive facets count.
  1196. */
  1197. exhaustiveFacetsCount: boolean;
  1198. /**
  1199. * The time that the API toke the process the request.
  1200. */
  1201. processingTimeMS?: number;
  1202. };
  1203. export declare type SearchIndex = {
  1204. /**
  1205. * The application id.
  1206. */
  1207. readonly appId: string;
  1208. /**
  1209. * The index name.
  1210. */
  1211. readonly indexName: string;
  1212. /**
  1213. * The underlying transporter.
  1214. */
  1215. readonly transporter: Transporter;
  1216. };
  1217. export declare type SearchOptions = {
  1218. /**
  1219. * Create a new query with an empty search query.
  1220. */
  1221. readonly query?: string;
  1222. /**
  1223. * Allows a search for similar objects, but the query has to be constructed on your end and included alongside an empty query.
  1224. *
  1225. * The similarQuery should be made from the tags and keywords of the relevant object.
  1226. */
  1227. readonly similarQuery?: string;
  1228. /**
  1229. * Filter hits by facet value.
  1230. */
  1231. readonly facetFilters?: string | readonly string[] | ReadonlyArray<readonly string[] | string>;
  1232. /**
  1233. * Create filters for ranking purposes, where records that match the filter are ranked highest.
  1234. */
  1235. readonly optionalFilters?: string | readonly string[] | ReadonlyArray<readonly string[] | string>;
  1236. /**
  1237. * Filter on numeric attributes.
  1238. */
  1239. readonly numericFilters?: string | readonly string[] | ReadonlyArray<readonly string[] | string>;
  1240. /**
  1241. * Filter hits by tags. tagFilters is a different way of filtering, which relies on the _tags
  1242. * attribute. It uses a simpler syntax than filters. You can use it when you want to do
  1243. * simple filtering based on tags.
  1244. */
  1245. readonly tagFilters?: string | readonly string[] | ReadonlyArray<readonly string[] | string>;
  1246. /**
  1247. * Determines how to calculate the total score for filtering.
  1248. */
  1249. readonly sumOrFiltersScores?: boolean;
  1250. /**
  1251. * Filter the query with numeric, facet and/or tag filters.
  1252. */
  1253. readonly filters?: string;
  1254. /**
  1255. * Specify the page to retrieve.
  1256. */
  1257. readonly page?: number;
  1258. /**
  1259. * Set the number of hits per page.
  1260. */
  1261. readonly hitsPerPage?: number;
  1262. /**
  1263. * Specify the offset of the first hit to return.
  1264. */
  1265. readonly offset?: number;
  1266. /**
  1267. * Set the number of hits to retrieve (used only with offset).
  1268. */
  1269. readonly length?: number;
  1270. /**
  1271. * List of attributes to highlight.
  1272. */
  1273. readonly attributesToHighlight?: readonly string[];
  1274. /**
  1275. * List of attributes to snippet, with an optional maximum number of words to snippet.
  1276. */
  1277. readonly attributesToSnippet?: readonly string[];
  1278. /**
  1279. * Gives control over which attributes to retrieve and which not to retrieve.
  1280. */
  1281. readonly attributesToRetrieve?: readonly string[];
  1282. /**
  1283. * The HTML string to insert before the highlighted parts in all highlight and snippet results.
  1284. */
  1285. readonly highlightPreTag?: string;
  1286. /**
  1287. * The HTML string to insert after the highlighted parts in all highlight and snippet results
  1288. */
  1289. readonly highlightPostTag?: string;
  1290. /**
  1291. * String used as an ellipsis indicator when a snippet is truncated.
  1292. */
  1293. readonly snippetEllipsisText?: string;
  1294. /**
  1295. * Restrict highlighting and snippeting to items that matched the query.
  1296. */
  1297. readonly restrictHighlightAndSnippetArrays?: boolean;
  1298. /**
  1299. * Facets to retrieve.
  1300. */
  1301. readonly facets?: readonly string[];
  1302. /**
  1303. * Maximum number of facet values to return for each facet during a regular search.
  1304. */
  1305. readonly maxValuesPerFacet?: number;
  1306. /**
  1307. * Force faceting to be applied after de-duplication (via the Distinct setting).
  1308. */
  1309. readonly facetingAfterDistinct?: boolean;
  1310. /**
  1311. * Minimum number of characters a word in the query string must contain to accept matches with 1 typo
  1312. */
  1313. readonly minWordSizefor1Typo?: number;
  1314. /**
  1315. * Minimum number of characters a word in the query string must contain to accept matches with 2 typos.
  1316. */
  1317. readonly minWordSizefor2Typos?: number;
  1318. /**
  1319. * Whether to allow typos on numbers (“numeric tokens”) in the query string.
  1320. */
  1321. readonly allowTyposOnNumericTokens?: boolean;
  1322. /**
  1323. * List of attributes on which you want to disable typo tolerance.
  1324. */
  1325. readonly disableTypoToleranceOnAttributes?: readonly string[];
  1326. /**
  1327. * Controls if and how query words are interpreted as prefixes.
  1328. */
  1329. readonly queryType?: 'prefixLast' | 'prefixAll' | 'prefixNone';
  1330. /**
  1331. * Selects a strategy to remove words from the query when it doesn’t match any hits.
  1332. */
  1333. readonly removeWordsIfNoResults?: 'none' | 'lastWords' | 'firstWords' | 'allOptional';
  1334. /**
  1335. * Enables the advanced query syntax.
  1336. */
  1337. readonly advancedSyntax?: boolean;
  1338. /**
  1339. * AdvancedSyntaxFeatures can be exactPhrase or excludeWords
  1340. */
  1341. readonly advancedSyntaxFeatures?: ReadonlyArray<'exactPhrase' | 'excludeWords'>;
  1342. /**
  1343. * A list of words that should be considered as optional when found in the query.
  1344. */
  1345. readonly optionalWords?: string | readonly string[];
  1346. /**
  1347. * List of attributes on which you want to disable the exact ranking criterion.
  1348. */
  1349. readonly disableExactOnAttributes?: readonly string[];
  1350. /**
  1351. * Controls how the exact ranking criterion is computed when the query contains only one word.
  1352. */
  1353. readonly exactOnSingleWordQuery?: 'attribute' | 'none' | 'word';
  1354. /**
  1355. * List of alternatives that should be considered an exact match by the exact ranking criterion.
  1356. */
  1357. readonly alternativesAsExact?: ReadonlyArray<'ignorePlurals' | 'singleWordSynonym' | 'multiWordsSynonym'>;
  1358. /**
  1359. * Whether rules should be globally enabled.
  1360. */
  1361. readonly enableRules?: boolean;
  1362. /**
  1363. * Enables contextual rules.
  1364. */
  1365. readonly ruleContexts?: readonly string[];
  1366. /**
  1367. * Enables de-duplication or grouping of results.
  1368. */
  1369. readonly distinct?: boolean | number;
  1370. /**
  1371. * Whether the current query will be taken into account in the Analytics
  1372. */
  1373. readonly analytics?: boolean;
  1374. /**
  1375. * List of tags to apply to the query in the analytics.
  1376. */
  1377. readonly analyticsTags?: readonly string[];
  1378. /**
  1379. * Whether to take into account an index’s synonyms for a particular search.
  1380. */
  1381. readonly synonyms?: boolean;
  1382. /**
  1383. * Whether to highlight and snippet the original word that matches the synonym or the synonym itself.
  1384. */
  1385. readonly replaceSynonymsInHighlight?: boolean;
  1386. /**
  1387. * Precision of the proximity ranking criterion.
  1388. */
  1389. readonly minProximity?: number;
  1390. /**
  1391. * Choose which fields the response will contain. Applies to search and browse queries.
  1392. */
  1393. readonly responseFields?: readonly string[];
  1394. /**
  1395. * Maximum number of facet hits to return during a search for facet values.
  1396. */
  1397. readonly maxFacetHits?: number;
  1398. /**
  1399. * Whether to include or exclude a query from the processing-time percentile computation.
  1400. */
  1401. readonly percentileComputation?: boolean;
  1402. /**
  1403. * Enable the Click Analytics feature.
  1404. */
  1405. readonly clickAnalytics?: boolean;
  1406. /**
  1407. * The `personalizationImpact` parameter sets the percentage of the impact that personalization has on ranking records. The
  1408. * value must be between 0 and 100 (inclusive). This parameter will not be taken into account if `enablePersonalization`
  1409. * is **false**.
  1410. */
  1411. readonly personalizationImpact?: number;
  1412. /**
  1413. * Enable personalization for the query
  1414. */
  1415. readonly enablePersonalization?: boolean;
  1416. /**
  1417. * Restricts a given query to look in only a subset of your searchable attributes.
  1418. */
  1419. readonly restrictSearchableAttributes?: readonly string[];
  1420. /**
  1421. * Restricts a given query to look in only a subset of your searchable attributes.
  1422. */
  1423. readonly sortFacetValuesBy?: 'count' | 'alpha';
  1424. /**
  1425. * Controls whether typo tolerance is enabled and how it is applied.
  1426. */
  1427. readonly typoTolerance?: boolean | 'min' | 'strict';
  1428. /**
  1429. * Search for entries around a central geolocation, enabling a geo search within a circular area.
  1430. */
  1431. readonly aroundLatLng?: string;
  1432. /**
  1433. * Search for entries around a given location automatically computed from the requester’s IP address.
  1434. */
  1435. readonly aroundLatLngViaIP?: boolean;
  1436. /**
  1437. * Search for entries around a given location automatically computed from the requester’s IP address.
  1438. */
  1439. readonly aroundRadius?: number | 'all';
  1440. /**
  1441. * Precision of geo search (in meters), to add grouping by geo location to the ranking formula.
  1442. */
  1443. readonly aroundPrecision?: number | ReadonlyArray<{
  1444. readonly from: number;
  1445. readonly value: number;
  1446. }>;
  1447. /**
  1448. * Minimum radius (in meters) used for a geo search when aroundRadius is not set.
  1449. */
  1450. readonly minimumAroundRadius?: number;
  1451. /**
  1452. * Search inside a rectangular area (in geo coordinates).
  1453. */
  1454. readonly insideBoundingBox?: ReadonlyArray<readonly number[]> | string;
  1455. /**
  1456. * Search inside a polygon (in geo coordinates).
  1457. */
  1458. readonly insidePolygon?: ReadonlyArray<readonly number[]>;
  1459. /**
  1460. * Treats singular, plurals, and other forms of declensions as matching terms.
  1461. */
  1462. readonly ignorePlurals?: boolean | readonly string[];
  1463. /**
  1464. * Removes stop (common) words from the query before executing it.
  1465. */
  1466. readonly removeStopWords?: boolean | readonly string[];
  1467. /**
  1468. * List of supported languages with their associated language ISO code.
  1469. *
  1470. * Apply a set of natural language best practices such as ignorePlurals,
  1471. * removeStopWords, removeWordsIfNoResults, analyticsTags and ruleContexts.
  1472. */
  1473. readonly naturalLanguages?: readonly string[];
  1474. /**
  1475. * When true, each hit in the response contains an additional _rankingInfo object.
  1476. */
  1477. readonly getRankingInfo?: boolean;
  1478. /**
  1479. * A user identifier.
  1480. * Format: alpha numeric string [a-zA-Z0-9_-]
  1481. * Length: between 1 and 64 characters.
  1482. */
  1483. readonly userToken?: string;
  1484. /**
  1485. * Can be to enable or disable A/B tests at query time.
  1486. * Engine's default: true
  1487. */
  1488. readonly enableABTest?: boolean;
  1489. /**
  1490. * Enable word segmentation (also called decompounding) at query time for
  1491. * compatible languages. For example, this turns the Dutch query
  1492. * "spaanplaatbehang" into "spaan plaat behang" to retrieve more relevant
  1493. * results.
  1494. */
  1495. readonly decompoundQuery?: boolean;
  1496. /**
  1497. * The relevancy threshold to apply to search in a virtual index [0-100]. A Bigger
  1498. * value means fewer, but more relevant results, smaller value means more, but
  1499. * less relevant results.
  1500. */
  1501. readonly relevancyStrictness?: number;
  1502. /**
  1503. * Whether this search should use Dynamic Re-Ranking.
  1504. * @link https://www.algolia.com/doc/guides/algolia-ai/re-ranking/
  1505. *
  1506. * Note: You need to turn on Dynamic Re-Ranking on your index for it to have an effect on
  1507. * your search results. You can do this through the Re-Ranking page on the dashboard.
  1508. * This parameter is only used to turn off Dynamic Re-Ranking (with false) at search time.
  1509. */
  1510. readonly enableReRanking?: boolean;
  1511. /**
  1512. * When Dynamic Re-Ranking is enabled, only records that match these filters will be impacted by Dynamic Re-Ranking.
  1513. */
  1514. readonly reRankingApplyFilter?: string | readonly string[] | ReadonlyArray<readonly string[] | string> | null;
  1515. };
  1516. export declare type SearchResponse<TObject = {}> = {
  1517. /**
  1518. * The hits returned by the search.
  1519. *
  1520. * Hits are ordered according to the ranking or sorting of the index being queried.
  1521. */
  1522. hits: Array<Hit<TObject>>;
  1523. /**
  1524. * Index of the current page (zero-based).
  1525. */
  1526. page: number;
  1527. /**
  1528. * Number of hits returned (used only with offset)
  1529. */
  1530. length?: number;
  1531. /**
  1532. * The offset of the first hit to returned.
  1533. */
  1534. offset?: number;
  1535. /**
  1536. * Number of hits matched by the query.
  1537. */
  1538. nbHits: number;
  1539. /**
  1540. * Subset of hits selected when relevancyStrictness is applied.
  1541. */
  1542. nbSortedHits?: number;
  1543. /**
  1544. * Number of pages returned.
  1545. *
  1546. * Calculation is based on the total number of hits (nbHits) divided by the
  1547. * number of hits per page (hitsPerPage), rounded up to the nearest integer.
  1548. */
  1549. nbPages: number;
  1550. /**
  1551. * Maximum number of hits returned per page.
  1552. */
  1553. hitsPerPage: number;
  1554. /**
  1555. * Time the server took to process the request, in milliseconds. This does not include network time.
  1556. */
  1557. processingTimeMS: number;
  1558. /**
  1559. * Whether the nbHits is exhaustive (true) or approximate (false).
  1560. *
  1561. * An approximation is done when the query takes more than 50ms to be
  1562. * processed (this can happen when using complex filters on millions on records).
  1563. */
  1564. exhaustiveNbHits: boolean;
  1565. /**
  1566. * Whether the facet count is exhaustive (true) or approximate (false).
  1567. */
  1568. exhaustiveFacetsCount?: boolean;
  1569. /**
  1570. * A mapping of each facet name to the corresponding facet counts.
  1571. */
  1572. facets?: Record<string, Record<string, number>>;
  1573. /**
  1574. * Statistics for numerical facets.
  1575. */
  1576. facets_stats?: Record<string, {
  1577. /**
  1578. * The minimum value in the result set.
  1579. */
  1580. min: number;
  1581. /**
  1582. * The maximum value in the result set.
  1583. */
  1584. max: number;
  1585. /**
  1586. * The average facet value in the result set.
  1587. */
  1588. avg: number;
  1589. /**
  1590. * The sum of all values in the result set.
  1591. */
  1592. sum: number;
  1593. }>;
  1594. /**
  1595. * The query used to search. Accepts every character, and every character entered will be used in the search.
  1596. *
  1597. * An empty query can be used to fetch all records.
  1598. */
  1599. query: string;
  1600. /**
  1601. * A markup text indicating which parts of the original query have been removed in order to retrieve a non-empty result set.
  1602. */
  1603. queryAfterRemoval?: string;
  1604. /**
  1605. * A url-encoded string of all search parameters.
  1606. */
  1607. params: string;
  1608. /**
  1609. * Unique identifier of the search query, to be sent in Insights methods. This identifier links events back to the search query it represents.
  1610. *
  1611. * Returned only if clickAnalytics is true.
  1612. */
  1613. queryID?: string;
  1614. /**
  1615. * Used to return warnings about the query.
  1616. */
  1617. message?: string;
  1618. /**
  1619. * The computed geo location.
  1620. *
  1621. * Format: "lat,lng", where the latitude and longitude are expressed as decimal floating point number.
  1622. */
  1623. aroundLatLng?: string;
  1624. /**
  1625. * The automatically computed radius.
  1626. */
  1627. automaticRadius?: string;
  1628. /**
  1629. * Actual host name of the server that processed the request.
  1630. *
  1631. * Our DNS supports automatic failover and load balancing, so this may differ from the host name used in the request.
  1632. */
  1633. serverUsed?: string;
  1634. /**
  1635. * Index name used for the query.
  1636. */
  1637. index?: string;
  1638. /**
  1639. * Index name used for the query. In case of AB test, the index targetted isn’t always the index used by the query.
  1640. */
  1641. indexUsed?: string;
  1642. /**
  1643. * In case of AB test, reports the variant ID used. The variant ID is the position in the array of variants (starting at 1).
  1644. */
  1645. abTestVariantID?: number;
  1646. /**
  1647. * The query string that will be searched, after normalization.
  1648. */
  1649. parsedQuery?: string;
  1650. /**
  1651. * Custom user data.
  1652. */
  1653. userData?: any;
  1654. /**
  1655. * Rules applied to the query.
  1656. */
  1657. appliedRules?: Array<Record<string, any>>;
  1658. /**
  1659. * The explanation of the decompounding at query time.
  1660. */
  1661. explain?: {
  1662. /**
  1663. * The explain query match.
  1664. */
  1665. match: {
  1666. /**
  1667. * The explain query match alternatives.
  1668. */
  1669. alternatives: Array<{
  1670. /**
  1671. * The alternative type.
  1672. */
  1673. types: string[];
  1674. /**
  1675. * The list of alternative words.
  1676. */
  1677. words: string[];
  1678. /**
  1679. * The number of typos.
  1680. */
  1681. typos: number;
  1682. /**
  1683. * The offset.
  1684. */
  1685. offset: number;
  1686. /**
  1687. * The length.
  1688. */
  1689. length: number;
  1690. }>;
  1691. };
  1692. /**
  1693. * Query parameter reporting. Parameters are reported
  1694. * as a JSON object with one field per parameter.
  1695. */
  1696. params?: Record<string, any>;
  1697. };
  1698. /**
  1699. * The relevancy threshold applied to search in a virtual index.
  1700. */
  1701. appliedRelevancyStrictness?: number;
  1702. renderingContent?: Settings['renderingContent'];
  1703. };
  1704. export declare const searchRules: (base: SearchIndex) => (query: string, requestOptions?: (RequestOptions & SearchRulesOptions) | undefined) => Readonly<Promise<SearchResponse<Rule>>>;
  1705. export declare type SearchRulesOptions = {
  1706. /**
  1707. * Full text query.
  1708. */
  1709. readonly query?: string;
  1710. /**
  1711. * When specified, restricts matches to rules with a specific anchoring type. When omitted, all anchoring types may match.
  1712. */
  1713. readonly anchoring?: string;
  1714. /**
  1715. * Restricts matches to contextual rules with a specific context (exact match).
  1716. */
  1717. readonly context?: string;
  1718. /**
  1719. * Requested page (zero-based).
  1720. */
  1721. readonly page?: number;
  1722. /**
  1723. * Maximum number of hits in a page. Minimum is 1, maximum is 1000.
  1724. */
  1725. readonly hitsPerPage?: number;
  1726. /**
  1727. * When specified, restricts matches to rules with a specific enabled status.
  1728. * When absent (default), all rules are retrieved, regardless of their enabled status.
  1729. */
  1730. readonly enabled?: boolean;
  1731. };
  1732. export declare const searchSynonyms: (base: SearchIndex) => (query: string, requestOptions?: (SearchSynonymsOptions & RequestOptions) | undefined) => Readonly<Promise<SearchSynonymsResponse>>;
  1733. export declare type SearchSynonymsOptions = {
  1734. /**
  1735. * The synonym type.
  1736. */
  1737. readonly type?: string;
  1738. /**
  1739. * Page to retrieve.
  1740. */
  1741. readonly page?: number;
  1742. /**
  1743. * Number of hits per page.
  1744. */
  1745. readonly hitsPerPage?: number;
  1746. };
  1747. export declare type SearchSynonymsResponse = {
  1748. /**
  1749. * The list of synonyms.
  1750. */
  1751. hits: Synonym[];
  1752. /**
  1753. * The number of synonyms on the list.
  1754. */
  1755. nbHits: number;
  1756. };
  1757. export declare const searchUserIDs: (base: SearchClient) => (query: string, requestOptions?: (SearchUserIDsOptions & RequestOptions) | undefined) => Readonly<Promise<SearchUserIDsResponse>>;
  1758. export declare type SearchUserIDsOptions = {
  1759. /**
  1760. * If specified, only clusters assigned to this cluster can be returned.
  1761. * */
  1762. readonly cluster?: string;
  1763. /**
  1764. * Page to fetch.
  1765. */
  1766. readonly page?: number;
  1767. /**
  1768. * Number of users to return by page.
  1769. */
  1770. readonly hitsPerPage?: number;
  1771. };
  1772. export declare type SearchUserIDsResponse = {
  1773. /**
  1774. * List of userID matching the query.
  1775. */
  1776. hits: UserIDResponse[];
  1777. /**
  1778. * Current page.
  1779. */
  1780. page: number;
  1781. /**
  1782. * Number of userIDs matching the query.
  1783. */
  1784. nbHits: number;
  1785. /**
  1786. * Number of hits retrieved per page.
  1787. */
  1788. hitsPerPage: number;
  1789. /**
  1790. * Timestamp of the last update of the index.
  1791. */
  1792. updatedAt: number;
  1793. };
  1794. export declare type SecuredApiKeyRestrictions = SearchOptions & {
  1795. /**
  1796. * A Unix timestamp used to define the expiration date of the API key.
  1797. */
  1798. readonly validUntil?: number;
  1799. /**
  1800. * List of index names that can be queried.
  1801. */
  1802. readonly restrictIndices?: readonly string[] | string;
  1803. /**
  1804. * IPv4 network allowed to use the generated key. This is used for more protection against API key leaking and reuse.
  1805. */
  1806. readonly restrictSources?: string;
  1807. /**
  1808. * Specify a user identifier. This is often used with rate limits.
  1809. */
  1810. readonly userToken?: string;
  1811. };
  1812. export declare const setDictionarySettings: (base: SearchClient) => (settings: DictionarySettings, requestOptions?: RequestOptions | undefined) => Readonly<WaitablePromise<DictionaryEntriesResponse>>;
  1813. export declare const setSettings: (base: SearchIndex) => (settings: Settings, requestOptions?: (RequestOptions & SetSettingsOptions) | undefined) => Readonly<WaitablePromise<SetSettingsResponse>>;
  1814. export declare type SetSettingsOptions = {
  1815. /**
  1816. * If the saved settings should be forward to replicas.
  1817. */
  1818. readonly forwardToReplicas?: boolean;
  1819. };
  1820. export declare type SetSettingsResponse = {
  1821. /**
  1822. * The operation task id. May be used to perform a wait task.
  1823. */
  1824. taskID: number;
  1825. /**
  1826. * When the settings got updated.
  1827. */
  1828. updatedAt: number;
  1829. };
  1830. export declare type Settings = {
  1831. /**
  1832. * The complete list of attributes that will be used for searching.
  1833. */
  1834. readonly searchableAttributes?: readonly string[];
  1835. /**
  1836. * @deprecated Use `searchableAttributes` instead.
  1837. */
  1838. readonly attributesToIndex?: readonly string[];
  1839. /**
  1840. * The complete list of attributes that will be used for faceting.
  1841. */
  1842. readonly attributesForFaceting?: readonly string[];
  1843. /**
  1844. * List of attributes that cannot be retrieved at query time.
  1845. */
  1846. readonly unretrievableAttributes?: readonly string[];
  1847. /**
  1848. * Gives control over which attributes to retrieve and which not to retrieve.
  1849. */
  1850. readonly attributesToRetrieve?: readonly string[];
  1851. /**
  1852. * Controls the way results are sorted.
  1853. */
  1854. readonly ranking?: readonly string[];
  1855. /**
  1856. * Specifies the custom ranking criterion.
  1857. */
  1858. readonly customRanking?: readonly string[];
  1859. /**
  1860. * Creates replicas, exact copies of an index.
  1861. */
  1862. readonly replicas?: readonly string[];
  1863. /**
  1864. * @deprecated Use `replicas` instead.
  1865. */
  1866. readonly slaves?: readonly string[];
  1867. /**
  1868. * The primary parameter is automatically added to a replica's settings when the replica is created and cannot be modified.
  1869. *
  1870. * Can not be setted.
  1871. */
  1872. readonly primary?: string;
  1873. /**
  1874. * Maximum number of facet values to return for each facet during a regular search.
  1875. */
  1876. readonly maxValuesPerFacet?: number;
  1877. /**
  1878. * Controls how facet values are sorted.
  1879. */
  1880. readonly sortFacetValuesBy?: 'count' | 'alpha';
  1881. /**
  1882. * List of attributes to highlight.
  1883. */
  1884. readonly attributesToHighlight?: readonly string[];
  1885. /**
  1886. * List of attributes to snippet, with an optional maximum number of words to snippet.
  1887. */
  1888. readonly attributesToSnippet?: readonly string[];
  1889. /**
  1890. * The HTML string to insert before the highlighted parts in all highlight and snippet results.
  1891. */
  1892. readonly highlightPreTag?: string;
  1893. /**
  1894. * The HTML string to insert after the highlighted parts in all highlight and snippet results.
  1895. */
  1896. readonly highlightPostTag?: string;
  1897. /**
  1898. * String used as an ellipsis indicator when a snippet is truncated.
  1899. */
  1900. readonly snippetEllipsisText?: string;
  1901. /**
  1902. * Restrict highlighting and snippeting to items that matched the query.
  1903. */
  1904. readonly restrictHighlightAndSnippetArrays?: boolean;
  1905. /**
  1906. * Set the number of hits per page.
  1907. */
  1908. readonly hitsPerPage?: number;
  1909. /**
  1910. * Set the maximum number of hits accessible via pagination.
  1911. */
  1912. readonly paginationLimitedTo?: number;
  1913. /**
  1914. * Minimum number of characters a word in the query string must contain to accept matches with 1 typo.
  1915. */
  1916. readonly minWordSizefor1Typo?: number;
  1917. /**
  1918. * Minimum number of characters a word in the query string must contain to accept matches with 2 typos.
  1919. */
  1920. readonly minWordSizefor2Typos?: number;
  1921. /**
  1922. * Controls whether typo tolerance is enabled and how it is applied.
  1923. */
  1924. readonly typoTolerance?: string | boolean;
  1925. /**
  1926. * hether to allow typos on numbers (“numeric tokens”) in the query string.
  1927. */
  1928. readonly allowTyposOnNumericTokens?: boolean;
  1929. /**
  1930. * List of attributes on which you want to disable typo tolerance.
  1931. */
  1932. readonly disableTypoToleranceOnAttributes?: readonly string[];
  1933. /**
  1934. * List of words on which you want to disable typo tolerance.
  1935. */
  1936. readonly disableTypoToleranceOnWords?: readonly string[];
  1937. /**
  1938. * Control which separators are indexed.
  1939. */
  1940. readonly separatorsToIndex?: string;
  1941. /**
  1942. * Treats singular, plurals, and other forms of declensions as matching terms.
  1943. */
  1944. readonly ignorePlurals?: readonly string[] | boolean;
  1945. /**
  1946. * Sets the languages to be used by language-specific settings and functionalities such as ignorePlurals, removeStopWords, and CJK word-detection.
  1947. */
  1948. readonly queryLanguages?: readonly string[];
  1949. /**
  1950. * A list of language ISO code.
  1951. */
  1952. readonly indexLanguages?: readonly string[];
  1953. /**
  1954. * Whether rules should be globally enabled.
  1955. */
  1956. readonly enableRules?: boolean;
  1957. /**
  1958. * Controls if and how query words are interpreted as prefixes.
  1959. */
  1960. readonly queryType?: 'prefixLast' | 'prefixAll' | 'prefixNone';
  1961. /**
  1962. * Selects a strategy to remove words from the query when it doesn’t match any hits.
  1963. */
  1964. readonly removeWordsIfNoResults?: 'none' | 'lastWords' | 'firstWords' | 'allOptional';
  1965. /**
  1966. * Enables the advanced query syntax.
  1967. */
  1968. readonly advancedSyntax?: boolean;
  1969. /**
  1970. * AdvancedSyntaxFeatures can be exactPhrase or excludeWords
  1971. */
  1972. readonly advancedSyntaxFeatures?: ReadonlyArray<'exactPhrase' | 'excludeWords'>;
  1973. /**
  1974. * A list of words that should be considered as optional when found in the query.
  1975. */
  1976. readonly optionalWords?: readonly string[];
  1977. /**
  1978. * List of attributes on which you want to disable prefix matching.
  1979. */
  1980. readonly disablePrefixOnAttributes?: readonly string[];
  1981. /**
  1982. * List of attributes on which you want to disable the exact ranking criterion.
  1983. */
  1984. readonly disableExactOnAttributes?: readonly string[];
  1985. /**
  1986. * Controls how the exact ranking criterion is computed when the query contains only one word.
  1987. */
  1988. readonly exactOnSingleWordQuery?: 'attribute' | 'none' | 'word';
  1989. /**
  1990. * List of alternatives that should be considered an exact match by the exact ranking criterion.
  1991. */
  1992. readonly alternativesAsExact?: ReadonlyArray<'ignorePlurals' | 'singleWordSynonym' | 'multiWordsSynonym'>;
  1993. /**
  1994. * Removes stop (common) words from the query before executing it.
  1995. */
  1996. readonly removeStopWords?: boolean | readonly string[];
  1997. /**
  1998. * List of numeric attributes that can be used as numerical filters.
  1999. */
  2000. readonly numericAttributesForFiltering?: readonly string[];
  2001. /**
  2002. * Enables compression of large integer arrays.
  2003. */
  2004. readonly allowCompressionOfIntegerArray?: boolean;
  2005. /**
  2006. * Name of the de-duplication attribute to be used with the distinct feature.
  2007. */
  2008. readonly attributeForDistinct?: string;
  2009. /**
  2010. * Enables de-duplication or grouping of results.
  2011. */
  2012. readonly distinct?: boolean | number;
  2013. /**
  2014. * Whether to highlight and snippet the original word that matches the synonym or the synonym itself.
  2015. */
  2016. readonly replaceSynonymsInHighlight?: boolean;
  2017. /**
  2018. * Allows proximity to impact which searchable attribute is matched in the attribute ranking stage.
  2019. */
  2020. readonly attributeCriteriaComputedByMinProximity?: boolean;
  2021. /**
  2022. * Precision of the proximity ranking criterion.
  2023. */
  2024. readonly minProximity?: number;
  2025. /**
  2026. * Choose which fields the response will contain. Applies to search and browse queries.
  2027. */
  2028. readonly responseFields?: readonly string[];
  2029. /**
  2030. * Maximum number of facet hits to return during a search for facet values.
  2031. */
  2032. readonly maxFacetHits?: number;
  2033. /**
  2034. * List of attributes on which to do a decomposition of camel case words.
  2035. */
  2036. readonly camelCaseAttributes?: readonly string[];
  2037. /**
  2038. * Specify on which attributes in your index Algolia should apply word-splitting (“decompounding”)
  2039. */
  2040. readonly decompoundedAttributes?: Readonly<Record<string, readonly string[]>>;
  2041. /**
  2042. * Characters that should not be automatically normalized by the search engine.
  2043. */
  2044. readonly keepDiacriticsOnCharacters?: string;
  2045. /**
  2046. * Overrides Algolia's default normalization.
  2047. */
  2048. readonly customNormalization?: Readonly<Record<string, Readonly<Record<string, string>>>>;
  2049. /**
  2050. * Enable personalization for queries by default
  2051. */
  2052. readonly enablePersonalization?: boolean;
  2053. /**
  2054. * Custom userData that could be added to the Settings.
  2055. */
  2056. readonly userData?: any;
  2057. /**
  2058. * Enable word segmentation (also called decompounding) at query time for
  2059. * compatible languages. For example, this turns the Dutch query
  2060. * "spaanplaatbehang" into "spaan plaat behang" to retrieve more relevant
  2061. * results.
  2062. */
  2063. readonly decompoundQuery?: boolean;
  2064. /**
  2065. * Specify on which attributes in your index Algolia should apply Japanese
  2066. * transliteration to make words indexed in Katakana or Kanji searchable in Hiragana.
  2067. */
  2068. readonly attributesToTransliterate?: readonly string[];
  2069. /**
  2070. * The relevancy threshold to apply to search in a virtual index [0-100]. A Bigger
  2071. * value means fewer, but more relevant results, smaller value means more, but
  2072. * less relevant results.
  2073. */
  2074. readonly relevancyStrictness?: number;
  2075. /**
  2076. * Content defining how the search interface should be rendered.
  2077. * This is set via the settings for a default value and can be overridden via rules
  2078. */
  2079. readonly renderingContent?: {
  2080. /**
  2081. * defining how facets should be ordered
  2082. */
  2083. readonly facetOrdering?: {
  2084. /**
  2085. * the ordering of facets (widgets)
  2086. */
  2087. readonly facets?: {
  2088. /**
  2089. * pinned order of facet lists
  2090. */
  2091. readonly order?: readonly string[];
  2092. };
  2093. /**
  2094. * the ordering of facet values, within an individual list
  2095. */
  2096. readonly values?: {
  2097. readonly [facet: string]: {
  2098. /**
  2099. * pinned order of facet values
  2100. */
  2101. readonly order?: readonly string[];
  2102. /**
  2103. * How to display the remaining items.
  2104. * - facet count (descending)
  2105. * - alphabetical (ascending)
  2106. * - hidden (show only pinned values)
  2107. */
  2108. readonly sortRemainingBy?: 'count' | 'alpha' | 'hidden';
  2109. };
  2110. };
  2111. };
  2112. };
  2113. /**
  2114. * Whether this index should use Dynamic Re-Ranking.
  2115. * @link https://www.algolia.com/doc/guides/algolia-ai/re-ranking/
  2116. *
  2117. * Note: You need to turn on Dynamic Re-Ranking on your index for it to have an effect on
  2118. * your search results. You can do this through the Re-Ranking page on the dashboard.
  2119. */
  2120. readonly enableReRanking?: boolean;
  2121. /**
  2122. * When Dynamic Re-Ranking is enabled, only records that match these filters will be impacted by Dynamic Re-Ranking.
  2123. */
  2124. readonly reRankingApplyFilter?: string | readonly string[] | ReadonlyArray<readonly string[] | string> | null;
  2125. };
  2126. declare type SharedMultipleQueriesQuery = {
  2127. /**
  2128. * The type of query to perform.
  2129. *
  2130. * @defaultValue "default"
  2131. */
  2132. readonly type?: 'default' | 'facet';
  2133. /**
  2134. * The index name.
  2135. */
  2136. readonly indexName: string;
  2137. /**
  2138. * The search options.
  2139. */
  2140. readonly params?: SearchOptions;
  2141. /**
  2142. * The query associated with the request.
  2143. */
  2144. readonly query?: string;
  2145. };
  2146. declare type SnippetMatch = {
  2147. readonly value: string;
  2148. readonly matchLevel: 'none' | 'partial' | 'full';
  2149. };
  2150. export declare type SnippetResult<THit> = THit extends string | number ? SnippetMatch : {
  2151. [KAttribute in keyof THit]: SnippetResult<THit[KAttribute]>;
  2152. };
  2153. export declare const StrategyEnum: Readonly<Record<string, StrategyType>>;
  2154. export declare type StrategyType = 'none' | 'stopIfEnoughMatches';
  2155. export declare type Synonym = {
  2156. /**
  2157. * Synonym object ID.
  2158. */
  2159. readonly objectID: string;
  2160. /**
  2161. * There are 4 synonym types. The parameter can be one of the following value.
  2162. */
  2163. readonly type: SynonymType;
  2164. /**
  2165. * A list of synonyms.
  2166. */
  2167. readonly synonyms?: readonly string[];
  2168. /**
  2169. * Defines the synonym. A word or expression, used as the basis for the array of synonyms.
  2170. */
  2171. readonly input?: string;
  2172. /**
  2173. * A single word, used as the basis for the below array of corrections.
  2174. */
  2175. readonly word?: string;
  2176. /**
  2177. * An list of corrections of the word.
  2178. */
  2179. readonly corrections?: readonly string[];
  2180. /**
  2181. * A single word, used as the basis for the below list of replacements.
  2182. */
  2183. readonly placeholder?: string;
  2184. /**
  2185. * An list of replacements of the placeholder.
  2186. */
  2187. readonly replacements?: readonly string[];
  2188. };
  2189. export declare const SynonymEnum: Readonly<Record<string, SynonymType>>;
  2190. export declare type SynonymType = 'synonym' | 'oneWaySynonym' | 'altCorrection1' | 'altCorrection2' | 'placeholder';
  2191. export declare type TaskStatusResponse = {
  2192. /**
  2193. * The operation status. When the value is `published` the
  2194. * operation is completed.
  2195. */
  2196. status: string;
  2197. /**
  2198. * If the operation is pending.
  2199. */
  2200. pendingTask: boolean;
  2201. };
  2202. export declare type TimeRange = {
  2203. /**
  2204. * DateTime with UTC offset for Serialization/Deserialization in unix timespan.
  2205. */
  2206. readonly from: number;
  2207. /**
  2208. * DateTime with UTC offset for Serialization/Deserialization in unix timespan.
  2209. */
  2210. readonly until: number;
  2211. };
  2212. export declare const updateApiKey: (base: SearchClient) => (apiKey: string, requestOptions?: (UpdateApiKeyOptions & Pick<RequestOptions, string | number>) | undefined) => Readonly<WaitablePromise<UpdateApiKeyResponse>>;
  2213. export declare type UpdateApiKeyOptions = {
  2214. /**
  2215. * List of permissions the key contains.
  2216. */
  2217. readonly acl?: readonly ApiKeyACLType[];
  2218. /**
  2219. * A Unix timestamp used to define the expiration date of the API key.
  2220. */
  2221. readonly validity?: number;
  2222. /**
  2223. * Specify the maximum number of hits this API key can retrieve in one call.
  2224. * This parameter can be used to protect you from attempts at retrieving your entire index contents by massively querying the index.
  2225. */
  2226. readonly maxHitsPerQuery?: number;
  2227. /**
  2228. * Specify the maximum number of API calls allowed from an IP address per hour. Each time an API call is performed with this key, a check is performed.
  2229. */
  2230. readonly maxQueriesPerIPPerHour?: number;
  2231. /**
  2232. * Specify the list of targeted indices. You can target all indices starting with a prefix or ending with a suffix using the ‘*’ character.
  2233. */
  2234. readonly indexes?: readonly string[];
  2235. /**
  2236. * Specify the list of referers. You can target all referers starting with a prefix, ending with a suffix using the ‘*’ character.
  2237. */
  2238. readonly referers?: readonly string[];
  2239. /**
  2240. * Specify the list of query parameters. You can force the query parameters for a query using the url string format.
  2241. */
  2242. readonly queryParameters?: string;
  2243. /**
  2244. * Specify a description of the API key. Used for informative purposes only. It has impact on the functionality of the API key.
  2245. */
  2246. readonly description?: string;
  2247. };
  2248. export declare type UpdateApiKeyResponse = {
  2249. /**
  2250. * The api key.
  2251. */
  2252. key: string;
  2253. /**
  2254. * Date of update
  2255. */
  2256. updatedAt: string;
  2257. };
  2258. export declare type UserIDResponse = {
  2259. /**
  2260. * userID of the user.
  2261. */
  2262. userID: string;
  2263. /**
  2264. * Cluster on which the user is assigned
  2265. */
  2266. clusterName: string;
  2267. /**
  2268. * Number of records belonging to the user.
  2269. */
  2270. nbRecords: number;
  2271. /**
  2272. * Data size used by the user.
  2273. */
  2274. dataSize: number;
  2275. };
  2276. export declare const waitAppTask: (base: SearchClient) => (taskID: number, requestOptions?: RequestOptions | undefined) => Readonly<Promise<void>>;
  2277. export declare const waitTask: (base: SearchIndex) => (taskID: number, requestOptions?: RequestOptions | undefined) => Readonly<Promise<void>>;
  2278. export { }