Skip to content

Commit 60a09e3

Browse files
algolia-botmillotp
andcommitted
add some coms (generated)
Co-authored-by: Pierre Millot <[email protected]>
1 parent 430b80d commit 60a09e3

File tree

28 files changed

+871
-69
lines changed

28 files changed

+871
-69
lines changed

clients/algoliasearch-client-go/algolia/search/api_search.go

Lines changed: 91 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/algoliasearch-client-java/algoliasearch/src/main/java/com/algolia/api/SearchClient.java

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6835,7 +6835,7 @@ public <T> ReplaceAllObjectsResponse replaceAllObjects(String indexName, Iterabl
68356835
* @throws AlgoliaRuntimeException When an error occurred during the serialization
68366836
*/
68376837
public <T> ReplaceAllObjectsResponse replaceAllObjects(String indexName, Iterable<T> objects, int batchSize) {
6838-
return replaceAllObjects(indexName, objects, batchSize, null);
6838+
return replaceAllObjects(indexName, objects, batchSize, null, null);
68396839
}
68406840

68416841
/**
@@ -6848,6 +6848,28 @@ public <T> ReplaceAllObjectsResponse replaceAllObjects(String indexName, Iterabl
68486848
* @param objects The array of `objects` to store in the given Algolia `indexName`.
68496849
* @param batchSize The size of the chunk of `objects`. The number of `batch` calls will be equal
68506850
* to `length(objects) / batchSize`.
6851+
* @param scopes The `scopes` to keep from the index. Defaults to ['settings', 'rules',
6852+
* 'synonyms'].
6853+
* @throws AlgoliaRetryException When the retry has failed on all hosts
6854+
* @throws AlgoliaApiException When the API sends an http error code
6855+
* @throws AlgoliaRuntimeException When an error occurred during the serialization
6856+
*/
6857+
public <T> ReplaceAllObjectsResponse replaceAllObjects(String indexName, Iterable<T> objects, int batchSize, List<ScopeType> scopes) {
6858+
return replaceAllObjects(indexName, objects, batchSize, scopes, null);
6859+
}
6860+
6861+
/**
6862+
* Push a new set of objects and remove all previous ones. Settings, synonyms and query rules are
6863+
* untouched. Replace all records in an index without any downtime. See
6864+
* https://api-clients-automation.netlify.app/docs/add-new-api-client#5-helpers for implementation
6865+
* details.
6866+
*
6867+
* @param indexName The `indexName` to replace `objects` in.
6868+
* @param objects The array of `objects` to store in the given Algolia `indexName`.
6869+
* @param batchSize The size of the chunk of `objects`. The number of `batch` calls will be equal
6870+
* to `length(objects) / batchSize`.
6871+
* @param scopes The `scopes` to keep from the index. Defaults to ['settings', 'rules',
6872+
* 'synonyms'].
68516873
* @param requestOptions The requestOptions to send along with the query, they will be merged with
68526874
* the transporter requestOptions. (optional)
68536875
* @throws AlgoliaRetryException When the retry has failed on all hosts
@@ -6858,6 +6880,7 @@ public <T> ReplaceAllObjectsResponse replaceAllObjects(
68586880
String indexName,
68596881
Iterable<T> objects,
68606882
int batchSize,
6883+
List<ScopeType> scopes,
68616884
RequestOptions requestOptions
68626885
) {
68636886
Random rnd = new Random();
@@ -6867,16 +6890,21 @@ public <T> ReplaceAllObjectsResponse replaceAllObjects(
68676890
batchSize = 1000;
68686891
}
68696892

6893+
if (scopes == null) {
6894+
scopes = new ArrayList<ScopeType>() {
6895+
{
6896+
add(ScopeType.SETTINGS);
6897+
add(ScopeType.RULES);
6898+
add(ScopeType.SYNONYMS);
6899+
}
6900+
};
6901+
}
6902+
68706903
try {
68716904
// Copy settings, synonyms and rules
68726905
UpdatedAtResponse copyOperationResponse = operationIndex(
68736906
indexName,
6874-
new OperationIndexParams()
6875-
.setOperation(OperationType.COPY)
6876-
.setDestination(tmpIndexName)
6877-
.addScope(ScopeType.SETTINGS)
6878-
.addScope(ScopeType.RULES)
6879-
.addScope(ScopeType.SYNONYMS),
6907+
new OperationIndexParams().setOperation(OperationType.COPY).setDestination(tmpIndexName).setScope(scopes),
68806908
requestOptions
68816909
);
68826910

@@ -6887,12 +6915,7 @@ public <T> ReplaceAllObjectsResponse replaceAllObjects(
68876915

68886916
copyOperationResponse = operationIndex(
68896917
indexName,
6890-
new OperationIndexParams()
6891-
.setOperation(OperationType.COPY)
6892-
.setDestination(tmpIndexName)
6893-
.addScope(ScopeType.SETTINGS)
6894-
.addScope(ScopeType.RULES)
6895-
.addScope(ScopeType.SYNONYMS),
6918+
new OperationIndexParams().setOperation(OperationType.COPY).setDestination(tmpIndexName).setScope(scopes),
68966919
requestOptions
68976920
);
68986921
waitForTask(tmpIndexName, copyOperationResponse.getTaskID(), requestOptions);

clients/algoliasearch-client-javascript/packages/client-search/model/clientMethodProps.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import type { OperationIndexParams } from '../model/operationIndexParams';
2323

2424
import type { Rule } from '../model/rule';
2525

26+
import type { ScopeType } from '../model/scopeType';
2627
import type { SearchDictionaryEntriesParams } from '../model/searchDictionaryEntriesParams';
2728

2829
import type { SearchForFacetValuesRequest } from '../model/searchForFacetValuesRequest';
@@ -870,4 +871,9 @@ export type ReplaceAllObjectsOptions = {
870871
* The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
871872
*/
872873
batchSize?: number;
874+
875+
/**
876+
* The `scopes` to keep from the index. Defaults to ['settings', 'rules', 'synonyms'].
877+
*/
878+
scopes?: Array<ScopeType>;
873879
};

clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -633,23 +633,28 @@ export function createSearchClient({
633633
* @param replaceAllObjects.indexName - The `indexName` to replace `objects` in.
634634
* @param replaceAllObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
635635
* @param replaceAllObjects.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `objects.length / batchSize`. Defaults to 1000.
636+
* @param replaceAllObjects.scopes - The `scopes` to keep from the index. Defaults to ['settings', 'rules', 'synonyms'].
636637
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch`, `operationIndex` and `getTask` method and merged with the transporter requestOptions.
637638
*/
638639
async replaceAllObjects(
639-
{ indexName, objects, batchSize }: ReplaceAllObjectsOptions,
640+
{ indexName, objects, batchSize, scopes }: ReplaceAllObjectsOptions,
640641
requestOptions?: RequestOptions,
641642
): Promise<ReplaceAllObjectsResponse> {
642643
const randomSuffix = Math.floor(Math.random() * 1000000) + 100000;
643644
const tmpIndexName = `${indexName}_tmp_${randomSuffix}`;
644645

646+
if (scopes === undefined) {
647+
scopes = ['settings', 'rules', 'synonyms'];
648+
}
649+
645650
try {
646651
let copyOperationResponse = await this.operationIndex(
647652
{
648653
indexName,
649654
operationIndexParams: {
650655
operation: 'copy',
651656
destination: tmpIndexName,
652-
scope: ['settings', 'rules', 'synonyms'],
657+
scope: scopes,
653658
},
654659
},
655660
requestOptions,
@@ -671,7 +676,7 @@ export function createSearchClient({
671676
operationIndexParams: {
672677
operation: 'copy',
673678
destination: tmpIndexName,
674-
scope: ['settings', 'rules', 'synonyms'],
679+
scope: scopes,
675680
},
676681
},
677682
requestOptions,

0 commit comments

Comments
 (0)