@algolia/client-search 5.2.5 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,8 +10,15 @@ import {
10
10
  import { createXhrRequester } from "@algolia/requester-browser-xhr";
11
11
 
12
12
  // src/searchClient.ts
13
- import { createAuth, createTransporter, getAlgoliaAgent, shuffle, createIterablePromise } from "@algolia/client-common";
14
- var apiClientVersion = "5.2.5";
13
+ import {
14
+ createAuth,
15
+ createTransporter,
16
+ getAlgoliaAgent,
17
+ shuffle,
18
+ ApiError,
19
+ createIterablePromise
20
+ } from "@algolia/client-common";
21
+ var apiClientVersion = "5.3.0";
15
22
  function getDefaultHosts(appId) {
16
23
  return [
17
24
  {
@@ -52,26 +59,25 @@ function createSearchClient({
52
59
  ...options
53
60
  }) {
54
61
  const auth = createAuth(appIdOption, apiKeyOption, authMode);
55
- const transporter = createTransporter({
56
- hosts: getDefaultHosts(appIdOption),
57
- ...options,
58
- algoliaAgent: getAlgoliaAgent({
59
- algoliaAgents,
60
- client: "Search",
61
- version: apiClientVersion
62
- }),
63
- baseHeaders: {
64
- "content-type": "text/plain",
65
- ...auth.headers(),
66
- ...options.baseHeaders
67
- },
68
- baseQueryParameters: {
69
- ...auth.queryParameters(),
70
- ...options.baseQueryParameters
71
- }
72
- });
73
62
  return {
74
- transporter,
63
+ transporter: createTransporter({
64
+ hosts: getDefaultHosts(appIdOption),
65
+ ...options,
66
+ algoliaAgent: getAlgoliaAgent({
67
+ algoliaAgents,
68
+ client: "Search",
69
+ version: apiClientVersion
70
+ }),
71
+ baseHeaders: {
72
+ "content-type": "text/plain",
73
+ ...auth.headers(),
74
+ ...options.baseHeaders
75
+ },
76
+ baseQueryParameters: {
77
+ ...auth.queryParameters(),
78
+ ...options.baseQueryParameters
79
+ }
80
+ }),
75
81
  /**
76
82
  * The `appId` currently in use.
77
83
  */
@@ -80,13 +86,15 @@ function createSearchClient({
80
86
  * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
81
87
  */
82
88
  clearCache() {
83
- return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => void 0);
89
+ return Promise.all([this.transporter.requestsCache.clear(), this.transporter.responsesCache.clear()]).then(
90
+ () => void 0
91
+ );
84
92
  },
85
93
  /**
86
94
  * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
87
95
  */
88
96
  get _ua() {
89
- return transporter.algoliaAgent.value;
97
+ return this.transporter.algoliaAgent.value;
90
98
  },
91
99
  /**
92
100
  * Adds a `segment` to the `x-algolia-agent` sent with every requests.
@@ -95,7 +103,16 @@ function createSearchClient({
95
103
  * @param version - The version of the agent.
96
104
  */
97
105
  addAlgoliaAgent(segment, version) {
98
- transporter.algoliaAgent.add({ segment, version });
106
+ this.transporter.algoliaAgent.add({ segment, version });
107
+ },
108
+ /**
109
+ * Helper method to switch the API key used to authenticate the requests.
110
+ *
111
+ * @param params - Method params.
112
+ * @param params.apiKey - The new API Key to use.
113
+ */
114
+ setClientApiKey({ apiKey }) {
115
+ this.transporter.baseHeaders["x-algolia-api-key"] = apiKey;
99
116
  },
100
117
  /**
101
118
  * Helper: Wait for a task to be published (completed) for a given `indexName` and `taskID`.
@@ -459,6 +476,17 @@ function createSearchClient({
459
476
  });
460
477
  return { copyOperationResponse, batchResponses, moveOperationResponse };
461
478
  },
479
+ async indexExists({ indexName }) {
480
+ try {
481
+ await this.getSettings({ indexName });
482
+ } catch (error) {
483
+ if (error instanceof ApiError && error.status === 404) {
484
+ return false;
485
+ }
486
+ throw error;
487
+ }
488
+ return true;
489
+ },
462
490
  /**
463
491
  * Helper: calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets.
464
492
  * Disclaimer: We don't assert that the parameters you pass to this method only contains `hits` requests to prevent impacting search performances, this helper is purely for typing purposes.
@@ -507,7 +535,7 @@ function createSearchClient({
507
535
  headers,
508
536
  data: apiKey
509
537
  };
510
- return transporter.request(request, requestOptions);
538
+ return this.transporter.request(request, requestOptions);
511
539
  },
512
540
  /**
513
541
  * If a record with the specified object ID exists, the existing record is replaced. Otherwise, a new record is added to the index. To update _some_ attributes of an existing record, use the [`partial` operation](#tag/Records/operation/partialUpdateObject) instead. To add, update, or replace multiple records, use the [`batch` operation](#tag/Records/operation/batch).
@@ -541,7 +569,7 @@ function createSearchClient({
541
569
  headers,
542
570
  data: body
543
571
  };
544
- return transporter.request(request, requestOptions);
572
+ return this.transporter.request(request, requestOptions);
545
573
  },
546
574
  /**
547
575
  * Adds a source to the list of allowed sources.
@@ -569,7 +597,7 @@ function createSearchClient({
569
597
  headers,
570
598
  data: source
571
599
  };
572
- return transporter.request(request, requestOptions);
600
+ return this.transporter.request(request, requestOptions);
573
601
  },
574
602
  /**
575
603
  * Assigns or moves a user ID to a cluster. The time it takes to move a user is proportional to the amount of data linked to the user ID.
@@ -605,7 +633,7 @@ function createSearchClient({
605
633
  headers,
606
634
  data: assignUserIdParams
607
635
  };
608
- return transporter.request(request, requestOptions);
636
+ return this.transporter.request(request, requestOptions);
609
637
  },
610
638
  /**
611
639
  * Adds, updates, or deletes records in one index with a single API request. Batching index updates reduces latency and increases data integrity. - Actions are applied in the order they\'re specified. - Actions are equivalent to the individual API requests of the same name.
@@ -635,7 +663,7 @@ function createSearchClient({
635
663
  headers,
636
664
  data: batchWriteParams
637
665
  };
638
- return transporter.request(request, requestOptions);
666
+ return this.transporter.request(request, requestOptions);
639
667
  },
640
668
  /**
641
669
  * Assigns multiple user IDs to a cluster. **You can\'t move users with this operation**.
@@ -674,7 +702,7 @@ function createSearchClient({
674
702
  headers,
675
703
  data: batchAssignUserIdsParams
676
704
  };
677
- return transporter.request(request, requestOptions);
705
+ return this.transporter.request(request, requestOptions);
678
706
  },
679
707
  /**
680
708
  * Adds or deletes multiple entries from your plurals, segmentation, or stop word dictionaries.
@@ -712,7 +740,7 @@ function createSearchClient({
712
740
  headers,
713
741
  data: batchDictionaryEntriesParams
714
742
  };
715
- return transporter.request(request, requestOptions);
743
+ return this.transporter.request(request, requestOptions);
716
744
  },
717
745
  /**
718
746
  * Retrieves records from an index, up to 1,000 per request. While searching retrieves _hits_ (records augmented with attributes for highlighting and ranking details), browsing _just_ returns matching records. This can be useful if you want to export your indices. - The Analytics API doesn\'t collect data when using `browse`. - Records are ranked by attributes and custom ranking. - There\'s no ranking for: typo-tolerance, number of matched words, proximity, geo distance. Browse requests automatically apply these settings: - `advancedSyntax`: `false` - `attributesToHighlight`: `[]` - `attributesToSnippet`: `[]` - `distinct`: `false` - `enablePersonalization`: `false` - `enableRules`: `false` - `facets`: `[]` - `getRankingInfo`: `false` - `ignorePlurals`: `false` - `optionalFilters`: `[]` - `typoTolerance`: `true` or `false` (`min` and `strict` is evaluated to `true`) If you send these parameters with your browse requests, they\'ll be ignored.
@@ -739,7 +767,7 @@ function createSearchClient({
739
767
  headers,
740
768
  data: browseParams ? browseParams : {}
741
769
  };
742
- return transporter.request(request, requestOptions);
770
+ return this.transporter.request(request, requestOptions);
743
771
  },
744
772
  /**
745
773
  * Deletes only the records from an index while keeping settings, synonyms, and rules.
@@ -764,7 +792,7 @@ function createSearchClient({
764
792
  queryParameters,
765
793
  headers
766
794
  };
767
- return transporter.request(request, requestOptions);
795
+ return this.transporter.request(request, requestOptions);
768
796
  },
769
797
  /**
770
798
  * Deletes all rules from the index.
@@ -793,7 +821,7 @@ function createSearchClient({
793
821
  queryParameters,
794
822
  headers
795
823
  };
796
- return transporter.request(request, requestOptions);
824
+ return this.transporter.request(request, requestOptions);
797
825
  },
798
826
  /**
799
827
  * Deletes all synonyms from the index.
@@ -822,7 +850,7 @@ function createSearchClient({
822
850
  queryParameters,
823
851
  headers
824
852
  };
825
- return transporter.request(request, requestOptions);
853
+ return this.transporter.request(request, requestOptions);
826
854
  },
827
855
  /**
828
856
  * This method allow you to send requests to the Algolia REST API.
@@ -845,7 +873,7 @@ function createSearchClient({
845
873
  queryParameters,
846
874
  headers
847
875
  };
848
- return transporter.request(request, requestOptions);
876
+ return this.transporter.request(request, requestOptions);
849
877
  },
850
878
  /**
851
879
  * This method allow you to send requests to the Algolia REST API.
@@ -868,7 +896,7 @@ function createSearchClient({
868
896
  queryParameters,
869
897
  headers
870
898
  };
871
- return transporter.request(request, requestOptions);
899
+ return this.transporter.request(request, requestOptions);
872
900
  },
873
901
  /**
874
902
  * This method allow you to send requests to the Algolia REST API.
@@ -893,7 +921,7 @@ function createSearchClient({
893
921
  headers,
894
922
  data: body ? body : {}
895
923
  };
896
- return transporter.request(request, requestOptions);
924
+ return this.transporter.request(request, requestOptions);
897
925
  },
898
926
  /**
899
927
  * This method allow you to send requests to the Algolia REST API.
@@ -918,7 +946,7 @@ function createSearchClient({
918
946
  headers,
919
947
  data: body ? body : {}
920
948
  };
921
- return transporter.request(request, requestOptions);
949
+ return this.transporter.request(request, requestOptions);
922
950
  },
923
951
  /**
924
952
  * Deletes the API key.
@@ -943,7 +971,7 @@ function createSearchClient({
943
971
  queryParameters,
944
972
  headers
945
973
  };
946
- return transporter.request(request, requestOptions);
974
+ return this.transporter.request(request, requestOptions);
947
975
  },
948
976
  /**
949
977
  * This operation doesn\'t accept empty queries or filters. It\'s more efficient to get a list of object IDs with the [`browse` operation](#tag/Search/operation/browse), and then delete the records using the [`batch` operation](#tag/Records/operation/batch).
@@ -973,7 +1001,7 @@ function createSearchClient({
973
1001
  headers,
974
1002
  data: deleteByParams
975
1003
  };
976
- return transporter.request(request, requestOptions);
1004
+ return this.transporter.request(request, requestOptions);
977
1005
  },
978
1006
  /**
979
1007
  * Deletes an index and all its settings. - Deleting an index doesn\'t delete its analytics data. - If you try to delete a non-existing index, the operation is ignored without warning. - If the index you want to delete has replica indices, the replicas become independent indices. - If the index you want to delete is a replica index, you must first unlink it from its primary index before you can delete it. For more information, see [Delete replica indices](https://www.algolia.com/doc/guides/managing-results/refine-results/sorting/how-to/deleting-replicas/).
@@ -998,7 +1026,7 @@ function createSearchClient({
998
1026
  queryParameters,
999
1027
  headers
1000
1028
  };
1001
- return transporter.request(request, requestOptions);
1029
+ return this.transporter.request(request, requestOptions);
1002
1030
  },
1003
1031
  /**
1004
1032
  * Deletes a record by its object ID. To delete more than one record, use the [`batch` operation](#tag/Records/operation/batch). To delete records matching a query, use the [`deleteByQuery` operation](#tag/Records/operation/deleteBy).
@@ -1027,7 +1055,7 @@ function createSearchClient({
1027
1055
  queryParameters,
1028
1056
  headers
1029
1057
  };
1030
- return transporter.request(request, requestOptions);
1058
+ return this.transporter.request(request, requestOptions);
1031
1059
  },
1032
1060
  /**
1033
1061
  * Deletes a rule by its ID. To find the object ID for rules, use the [`search` operation](#tag/Rules/operation/searchRules).
@@ -1060,7 +1088,7 @@ function createSearchClient({
1060
1088
  queryParameters,
1061
1089
  headers
1062
1090
  };
1063
- return transporter.request(request, requestOptions);
1091
+ return this.transporter.request(request, requestOptions);
1064
1092
  },
1065
1093
  /**
1066
1094
  * Deletes a source from the list of allowed sources.
@@ -1085,7 +1113,7 @@ function createSearchClient({
1085
1113
  queryParameters,
1086
1114
  headers
1087
1115
  };
1088
- return transporter.request(request, requestOptions);
1116
+ return this.transporter.request(request, requestOptions);
1089
1117
  },
1090
1118
  /**
1091
1119
  * Deletes a synonym by its ID. To find the object IDs of your synonyms, use the [`search` operation](#tag/Synonyms/operation/searchSynonyms).
@@ -1118,7 +1146,7 @@ function createSearchClient({
1118
1146
  queryParameters,
1119
1147
  headers
1120
1148
  };
1121
- return transporter.request(request, requestOptions);
1149
+ return this.transporter.request(request, requestOptions);
1122
1150
  },
1123
1151
  /**
1124
1152
  * Gets the permissions and restrictions of an API key. When authenticating with the admin API key, you can request information for any of your application\'s keys. When authenticating with other API keys, you can only retrieve information for that key.
@@ -1140,7 +1168,7 @@ function createSearchClient({
1140
1168
  queryParameters,
1141
1169
  headers
1142
1170
  };
1143
- return transporter.request(request, requestOptions);
1171
+ return this.transporter.request(request, requestOptions);
1144
1172
  },
1145
1173
  /**
1146
1174
  * Checks the status of a given application task.
@@ -1165,7 +1193,7 @@ function createSearchClient({
1165
1193
  queryParameters,
1166
1194
  headers
1167
1195
  };
1168
- return transporter.request(request, requestOptions);
1196
+ return this.transporter.request(request, requestOptions);
1169
1197
  },
1170
1198
  /**
1171
1199
  * Lists supported languages with their supported dictionary types and number of custom entries.
@@ -1185,7 +1213,7 @@ function createSearchClient({
1185
1213
  queryParameters,
1186
1214
  headers
1187
1215
  };
1188
- return transporter.request(request, requestOptions);
1216
+ return this.transporter.request(request, requestOptions);
1189
1217
  },
1190
1218
  /**
1191
1219
  * Retrieves the languages for which standard dictionary entries are turned off.
@@ -1205,7 +1233,7 @@ function createSearchClient({
1205
1233
  queryParameters,
1206
1234
  headers
1207
1235
  };
1208
- return transporter.request(request, requestOptions);
1236
+ return this.transporter.request(request, requestOptions);
1209
1237
  },
1210
1238
  /**
1211
1239
  * The request must be authenticated by an API key with the [`logs` ACL](https://www.algolia.com/doc/guides/security/api-keys/#access-control-list-acl). - Logs are held for the last seven days. - Up to 1,000 API requests per server are logged. - This request counts towards your [operations quota](https://support.algolia.com/hc/en-us/articles/4406981829777-How-does-Algolia-count-records-and-operations-) but doesn\'t appear in the logs itself.
@@ -1242,7 +1270,7 @@ function createSearchClient({
1242
1270
  queryParameters,
1243
1271
  headers
1244
1272
  };
1245
- return transporter.request(request, requestOptions);
1273
+ return this.transporter.request(request, requestOptions);
1246
1274
  },
1247
1275
  /**
1248
1276
  * Retrieves one record by its object ID. To retrieve more than one record, use the [`objects` operation](#tag/Records/operation/getObjects).
@@ -1275,7 +1303,7 @@ function createSearchClient({
1275
1303
  queryParameters,
1276
1304
  headers
1277
1305
  };
1278
- return transporter.request(request, requestOptions);
1306
+ return this.transporter.request(request, requestOptions);
1279
1307
  },
1280
1308
  /**
1281
1309
  * Retrieves one or more records, potentially from different indices. Records are returned in the same order as the requests.
@@ -1305,7 +1333,7 @@ function createSearchClient({
1305
1333
  useReadTransporter: true,
1306
1334
  cacheable: true
1307
1335
  };
1308
- return transporter.request(request, requestOptions);
1336
+ return this.transporter.request(request, requestOptions);
1309
1337
  },
1310
1338
  /**
1311
1339
  * Retrieves a rule by its ID. To find the object ID of rules, use the [`search` operation](#tag/Rules/operation/searchRules).
@@ -1334,7 +1362,7 @@ function createSearchClient({
1334
1362
  queryParameters,
1335
1363
  headers
1336
1364
  };
1337
- return transporter.request(request, requestOptions);
1365
+ return this.transporter.request(request, requestOptions);
1338
1366
  },
1339
1367
  /**
1340
1368
  * Retrieves an object with non-null index settings.
@@ -1359,7 +1387,7 @@ function createSearchClient({
1359
1387
  queryParameters,
1360
1388
  headers
1361
1389
  };
1362
- return transporter.request(request, requestOptions);
1390
+ return this.transporter.request(request, requestOptions);
1363
1391
  },
1364
1392
  /**
1365
1393
  * Retrieves all allowed IP addresses with access to your application.
@@ -1379,7 +1407,7 @@ function createSearchClient({
1379
1407
  queryParameters,
1380
1408
  headers
1381
1409
  };
1382
- return transporter.request(request, requestOptions);
1410
+ return this.transporter.request(request, requestOptions);
1383
1411
  },
1384
1412
  /**
1385
1413
  * Retrieves a syonym by its ID. To find the object IDs for your synonyms, use the [`search` operation](#tag/Synonyms/operation/searchSynonyms).
@@ -1408,7 +1436,7 @@ function createSearchClient({
1408
1436
  queryParameters,
1409
1437
  headers
1410
1438
  };
1411
- return transporter.request(request, requestOptions);
1439
+ return this.transporter.request(request, requestOptions);
1412
1440
  },
1413
1441
  /**
1414
1442
  * Checks the status of a given task. Indexing tasks are asynchronous. When you add, update, or delete records or indices, a task is created on a queue and completed depending on the load on the server. The indexing tasks\' responses include a task ID that you can use to check the status.
@@ -1437,7 +1465,7 @@ function createSearchClient({
1437
1465
  queryParameters,
1438
1466
  headers
1439
1467
  };
1440
- return transporter.request(request, requestOptions);
1468
+ return this.transporter.request(request, requestOptions);
1441
1469
  },
1442
1470
  /**
1443
1471
  * Get the IDs of the 10 users with the highest number of records per cluster. Since it can take a few seconds to get the data from the different clusters, the response isn\'t real-time.
@@ -1457,7 +1485,7 @@ function createSearchClient({
1457
1485
  queryParameters,
1458
1486
  headers
1459
1487
  };
1460
- return transporter.request(request, requestOptions);
1488
+ return this.transporter.request(request, requestOptions);
1461
1489
  },
1462
1490
  /**
1463
1491
  * Returns the user ID data stored in the mapping. Since it can take a few seconds to get the data from the different clusters, the response isn\'t real-time.
@@ -1482,7 +1510,7 @@ function createSearchClient({
1482
1510
  queryParameters,
1483
1511
  headers
1484
1512
  };
1485
- return transporter.request(request, requestOptions);
1513
+ return this.transporter.request(request, requestOptions);
1486
1514
  },
1487
1515
  /**
1488
1516
  * To determine when the time-consuming process of creating a large batch of users or migrating users from one cluster to another is complete, this operation retrieves the status of the process.
@@ -1507,7 +1535,7 @@ function createSearchClient({
1507
1535
  queryParameters,
1508
1536
  headers
1509
1537
  };
1510
- return transporter.request(request, requestOptions);
1538
+ return this.transporter.request(request, requestOptions);
1511
1539
  },
1512
1540
  /**
1513
1541
  * Lists all API keys associated with your Algolia application, including their permissions and restrictions.
@@ -1527,7 +1555,7 @@ function createSearchClient({
1527
1555
  queryParameters,
1528
1556
  headers
1529
1557
  };
1530
- return transporter.request(request, requestOptions);
1558
+ return this.transporter.request(request, requestOptions);
1531
1559
  },
1532
1560
  /**
1533
1561
  * Lists the available clusters in a multi-cluster setup.
@@ -1547,7 +1575,7 @@ function createSearchClient({
1547
1575
  queryParameters,
1548
1576
  headers
1549
1577
  };
1550
- return transporter.request(request, requestOptions);
1578
+ return this.transporter.request(request, requestOptions);
1551
1579
  },
1552
1580
  /**
1553
1581
  * Lists all indices in the current Algolia application. The request follows any index restrictions of the API key you use to make the request.
@@ -1576,7 +1604,7 @@ function createSearchClient({
1576
1604
  queryParameters,
1577
1605
  headers
1578
1606
  };
1579
- return transporter.request(request, requestOptions);
1607
+ return this.transporter.request(request, requestOptions);
1580
1608
  },
1581
1609
  /**
1582
1610
  * Lists the userIDs assigned to a multi-cluster application. Since it can take a few seconds to get the data from the different clusters, the response isn\'t real-time.
@@ -1605,7 +1633,7 @@ function createSearchClient({
1605
1633
  queryParameters,
1606
1634
  headers
1607
1635
  };
1608
- return transporter.request(request, requestOptions);
1636
+ return this.transporter.request(request, requestOptions);
1609
1637
  },
1610
1638
  /**
1611
1639
  * Adds, updates, or deletes records in multiple indices with a single API request. - Actions are applied in the order they are specified. - Actions are equivalent to the individual API requests of the same name.
@@ -1630,7 +1658,7 @@ function createSearchClient({
1630
1658
  headers,
1631
1659
  data: batchParams
1632
1660
  };
1633
- return transporter.request(request, requestOptions);
1661
+ return this.transporter.request(request, requestOptions);
1634
1662
  },
1635
1663
  /**
1636
1664
  * Copies or moves (renames) an index within the same Algolia application. - Existing destination indices are overwritten, except for their analytics data. - If the destination index doesn\'t exist yet, it\'ll be created. **Copy** - Copying a source index that doesn\'t exist creates a new index with 0 records and default settings. - The API keys of the source index are merged with the existing keys in the destination index. - You can\'t copy the `enableReRanking`, `mode`, and `replicas` settings. - You can\'t copy to a destination index that already has replicas. - Be aware of the [size limits](https://www.algolia.com/doc/guides/scaling/algolia-service-limits/#application-record-and-index-limits). - Related guide: [Copy indices](https://www.algolia.com/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/how-to/copy-indices/) **Move** - Moving a source index that doesn\'t exist is ignored without returning an error. - When moving an index, the analytics data keep their original name and a new set of analytics data is started for the new name. To access the original analytics in the dashboard, create an index with the original name. - If the destination index has replicas, moving will overwrite the existing index and copy the data to the replica indices. - Related guide: [Move indices](https://www.algolia.com/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/how-to/move-indices/).
@@ -1666,7 +1694,7 @@ function createSearchClient({
1666
1694
  headers,
1667
1695
  data: operationIndexParams
1668
1696
  };
1669
- return transporter.request(request, requestOptions);
1697
+ return this.transporter.request(request, requestOptions);
1670
1698
  },
1671
1699
  /**
1672
1700
  * Adds new attributes to a record, or update existing ones. - If a record with the specified object ID doesn\'t exist, a new record is added to the index **if** `createIfNotExists` is true. - If the index doesn\'t exist yet, this method creates a new index. - You can use any first-level attribute but not nested attributes. If you specify a nested attribute, the engine treats it as a replacement for its first-level ancestor. To update an attribute without pushing the entire record, you can use these built-in operations. These operations can be helpful if you don\'t have access to your initial data. - Increment: increment a numeric attribute - Decrement: decrement a numeric attribute - Add: append a number or string element to an array attribute - Remove: remove all matching number or string elements from an array attribute made of numbers or strings - AddUnique: add a number or string element to an array attribute made of numbers or strings only if it\'s not already present - IncrementFrom: increment a numeric integer attribute only if the provided value matches the current value, and otherwise ignore the whole object update. For example, if you pass an IncrementFrom value of 2 for the version attribute, but the current value of the attribute is 1, the engine ignores the update. If the object doesn\'t exist, the engine only creates it if you pass an IncrementFrom value of 0. - IncrementSet: increment a numeric integer attribute only if the provided value is greater than the current value, and otherwise ignore the whole object update. For example, if you pass an IncrementSet value of 2 for the version attribute, and the current value of the attribute is 1, the engine updates the object. If the object doesn\'t exist yet, the engine only creates it if you pass an IncrementSet value that\'s greater than 0. You can specify an operation by providing an object with the attribute to update as the key and its value being an object with the following properties: - _operation: the operation to apply on the attribute - value: the right-hand side argument to the operation, for example, increment or decrement step, value to add or remove.
@@ -1704,7 +1732,7 @@ function createSearchClient({
1704
1732
  headers,
1705
1733
  data: attributesToUpdate
1706
1734
  };
1707
- return transporter.request(request, requestOptions);
1735
+ return this.transporter.request(request, requestOptions);
1708
1736
  },
1709
1737
  /**
1710
1738
  * Deletes a user ID and its associated data from the clusters.
@@ -1729,7 +1757,7 @@ function createSearchClient({
1729
1757
  queryParameters,
1730
1758
  headers
1731
1759
  };
1732
- return transporter.request(request, requestOptions);
1760
+ return this.transporter.request(request, requestOptions);
1733
1761
  },
1734
1762
  /**
1735
1763
  * Replaces the list of allowed sources.
@@ -1755,7 +1783,7 @@ function createSearchClient({
1755
1783
  headers,
1756
1784
  data: source
1757
1785
  };
1758
- return transporter.request(request, requestOptions);
1786
+ return this.transporter.request(request, requestOptions);
1759
1787
  },
1760
1788
  /**
1761
1789
  * Restores a deleted API key. Restoring resets the `validity` attribute to `0`. Algolia stores up to 1,000 API keys per application. If you create more, the oldest API keys are deleted and can\'t be restored.
@@ -1780,7 +1808,7 @@ function createSearchClient({
1780
1808
  queryParameters,
1781
1809
  headers
1782
1810
  };
1783
- return transporter.request(request, requestOptions);
1811
+ return this.transporter.request(request, requestOptions);
1784
1812
  },
1785
1813
  /**
1786
1814
  * Adds a record to an index or replace it. - If the record doesn\'t have an object ID, a new record with an auto-generated object ID is added to your index. - If a record with the specified object ID exists, the existing record is replaced. - If a record with the specified object ID doesn\'t exist, a new record is added to your index. - If you add a record to an index that doesn\'t exist yet, a new index is created. To update _some_ attributes of a record, use the [`partial` operation](#tag/Records/operation/partialUpdateObject). To add, update, or replace multiple records, use the [`batch` operation](#tag/Records/operation/batch).
@@ -1810,7 +1838,7 @@ function createSearchClient({
1810
1838
  headers,
1811
1839
  data: body
1812
1840
  };
1813
- return transporter.request(request, requestOptions);
1841
+ return this.transporter.request(request, requestOptions);
1814
1842
  },
1815
1843
  /**
1816
1844
  * If a rule with the specified object ID doesn\'t exist, it\'s created. Otherwise, the existing rule is replaced. To create or update more than one rule, use the [`batch` operation](#tag/Rules/operation/saveRules).
@@ -1851,7 +1879,7 @@ function createSearchClient({
1851
1879
  headers,
1852
1880
  data: rule
1853
1881
  };
1854
- return transporter.request(request, requestOptions);
1882
+ return this.transporter.request(request, requestOptions);
1855
1883
  },
1856
1884
  /**
1857
1885
  * Create or update multiple rules. If a rule with the specified object ID doesn\'t exist, Algolia creates a new one. Otherwise, existing rules are replaced.
@@ -1889,7 +1917,7 @@ function createSearchClient({
1889
1917
  headers,
1890
1918
  data: rules
1891
1919
  };
1892
- return transporter.request(request, requestOptions);
1920
+ return this.transporter.request(request, requestOptions);
1893
1921
  },
1894
1922
  /**
1895
1923
  * If a synonym with the specified object ID doesn\'t exist, Algolia adds a new one. Otherwise, the existing synonym is replaced. To add multiple synonyms in a single API request, use the [`batch` operation](#tag/Synonyms/operation/saveSynonyms).
@@ -1933,7 +1961,7 @@ function createSearchClient({
1933
1961
  headers,
1934
1962
  data: synonymHit
1935
1963
  };
1936
- return transporter.request(request, requestOptions);
1964
+ return this.transporter.request(request, requestOptions);
1937
1965
  },
1938
1966
  /**
1939
1967
  * If a synonym with the `objectID` doesn\'t exist, Algolia adds a new one. Otherwise, existing synonyms are replaced.
@@ -1971,7 +1999,7 @@ function createSearchClient({
1971
1999
  headers,
1972
2000
  data: synonymHit
1973
2001
  };
1974
- return transporter.request(request, requestOptions);
2002
+ return this.transporter.request(request, requestOptions);
1975
2003
  },
1976
2004
  /**
1977
2005
  * Sends multiple search request to one or more indices. This can be useful in these cases: - Different indices for different purposes, such as, one index for products, another one for marketing content. - Multiple searches to the same index—for example, with different filters.
@@ -2022,7 +2050,7 @@ function createSearchClient({
2022
2050
  useReadTransporter: true,
2023
2051
  cacheable: true
2024
2052
  };
2025
- return transporter.request(request, requestOptions);
2053
+ return this.transporter.request(request, requestOptions);
2026
2054
  },
2027
2055
  /**
2028
2056
  * Searches for standard and custom dictionary entries.
@@ -2064,7 +2092,7 @@ function createSearchClient({
2064
2092
  useReadTransporter: true,
2065
2093
  cacheable: true
2066
2094
  };
2067
- return transporter.request(request, requestOptions);
2095
+ return this.transporter.request(request, requestOptions);
2068
2096
  },
2069
2097
  /**
2070
2098
  * Searches for values of a specified facet attribute. - By default, facet values are sorted by decreasing count. You can adjust this with the `sortFacetValueBy` parameter. - Searching for facet values doesn\'t work if you have **more than 65 searchable facets and searchable attributes combined**.
@@ -2097,7 +2125,7 @@ function createSearchClient({
2097
2125
  useReadTransporter: true,
2098
2126
  cacheable: true
2099
2127
  };
2100
- return transporter.request(request, requestOptions);
2128
+ return this.transporter.request(request, requestOptions);
2101
2129
  },
2102
2130
  /**
2103
2131
  * Searches for rules in your index.
@@ -2126,7 +2154,7 @@ function createSearchClient({
2126
2154
  useReadTransporter: true,
2127
2155
  cacheable: true
2128
2156
  };
2129
- return transporter.request(request, requestOptions);
2157
+ return this.transporter.request(request, requestOptions);
2130
2158
  },
2131
2159
  /**
2132
2160
  * Searches a single index and return matching search results (_hits_). This method lets you retrieve up to 1,000 hits. If you need more, use the [`browse` operation](#tag/Search/operation/browse) or increase the `paginatedLimitedTo` index setting.
@@ -2155,7 +2183,7 @@ function createSearchClient({
2155
2183
  useReadTransporter: true,
2156
2184
  cacheable: true
2157
2185
  };
2158
- return transporter.request(request, requestOptions);
2186
+ return this.transporter.request(request, requestOptions);
2159
2187
  },
2160
2188
  /**
2161
2189
  * Searches for synonyms in your index.
@@ -2187,7 +2215,7 @@ function createSearchClient({
2187
2215
  useReadTransporter: true,
2188
2216
  cacheable: true
2189
2217
  };
2190
- return transporter.request(request, requestOptions);
2218
+ return this.transporter.request(request, requestOptions);
2191
2219
  },
2192
2220
  /**
2193
2221
  * Since it can take a few seconds to get the data from the different clusters, the response isn\'t real-time. To ensure rapid updates, the user IDs index isn\'t built at the same time as the mapping. Instead, it\'s built every 12 hours, at the same time as the update of user ID usage. For example, if you add or move a user ID, the search will show an old value until the next time the mapping is rebuilt (every 12 hours).
@@ -2217,7 +2245,7 @@ function createSearchClient({
2217
2245
  useReadTransporter: true,
2218
2246
  cacheable: true
2219
2247
  };
2220
- return transporter.request(request, requestOptions);
2248
+ return this.transporter.request(request, requestOptions);
2221
2249
  },
2222
2250
  /**
2223
2251
  * Turns standard stop word dictionary entries on or off for a given language.
@@ -2247,7 +2275,7 @@ function createSearchClient({
2247
2275
  headers,
2248
2276
  data: dictionarySettingsParams
2249
2277
  };
2250
- return transporter.request(request, requestOptions);
2278
+ return this.transporter.request(request, requestOptions);
2251
2279
  },
2252
2280
  /**
2253
2281
  * Update the specified index settings. Index settings that you don\'t specify are left unchanged. Specify `null` to reset a setting to its default value. For best performance, update the index settings before you add new records to your index.
@@ -2281,7 +2309,7 @@ function createSearchClient({
2281
2309
  headers,
2282
2310
  data: indexSettings
2283
2311
  };
2284
- return transporter.request(request, requestOptions);
2312
+ return this.transporter.request(request, requestOptions);
2285
2313
  },
2286
2314
  /**
2287
2315
  * Replaces the permissions of an existing API key. Any unspecified attribute resets that attribute to its default value.
@@ -2314,7 +2342,7 @@ function createSearchClient({
2314
2342
  headers,
2315
2343
  data: apiKey
2316
2344
  };
2317
- return transporter.request(request, requestOptions);
2345
+ return this.transporter.request(request, requestOptions);
2318
2346
  }
2319
2347
  };
2320
2348
  }