Skip to content

Commit 47f71b9

Browse files
authored
feat(specs): add settings spec (#17)
1 parent 8997381 commit 47f71b9

32 files changed

+971
-797
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ yarn-error.log
1414
**/node_modules
1515
**/dist
1616
**/.openapi-generator-ignore
17+
**/git_push.sh

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

clients/algoliasearch-client-javascript/client-search/searchApi.ts

Lines changed: 90 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import { Requester } from '../utils/requester/Requester';
66
import { BatchObject } from '../model/batchObject';
77
import { BatchResponse } from '../model/batchResponse';
88
import { ErrorBase } from '../model/errorBase';
9+
import { IndexSettings } from '../model/indexSettings';
910
import { MultipleQueriesObject } from '../model/multipleQueriesObject';
1011
import { MultipleQueriesResponse } from '../model/multipleQueriesResponse';
1112
import { SaveObjectResponse } from '../model/saveObjectResponse';
1213
import { SearchParams } from '../model/searchParams';
13-
import { SearchParamsString } from '../model/searchParamsString';
14+
import { SearchParamsAsString } from '../model/searchParamsAsString';
1415
import { SearchResponse } from '../model/searchResponse';
16+
import { SetSettingsResponse } from '../model/setSettingsResponse';
1517
import { ApiKeyAuth } from '../model/models';
1618

1719
export enum SearchApiApiKeys {
@@ -120,6 +122,37 @@ export class SearchApi {
120122

121123
return this.sendRequest(request, requestOptions);
122124
}
125+
/**
126+
*
127+
* @summary Retrieve settings of a given indexName.
128+
* @param indexName The index in which to perform the request
129+
*/
130+
public async getSettings(indexName: string): Promise<IndexSettings> {
131+
const path = '/1/indexes/{indexName}/settings'.replace(
132+
'{' + 'indexName' + '}',
133+
encodeURIComponent(String(indexName))
134+
);
135+
let headers: Headers = { Accept: 'application/json' };
136+
let queryParameters: Record<string, string> = {};
137+
138+
if (indexName === null || indexName === undefined) {
139+
throw new Error(
140+
'Required parameter indexName was null or undefined when calling getSettings.'
141+
);
142+
}
143+
144+
const request: Request = {
145+
method: 'GET',
146+
path,
147+
};
148+
149+
const requestOptions: RequestOptions = {
150+
headers,
151+
queryParameters,
152+
};
153+
154+
return this.sendRequest(request, requestOptions);
155+
}
123156
/**
124157
*
125158
* @summary Get search results for the given requests.
@@ -197,11 +230,11 @@ export class SearchApi {
197230
*
198231
* @summary Get search results
199232
* @param indexName The index in which to perform the request
200-
* @param searchParamsSearchParamsString
233+
* @param searchParamsAsStringSearchParams
201234
*/
202235
public async search(
203236
indexName: string,
204-
searchParamsSearchParamsString: SearchParams | SearchParamsString
237+
searchParamsAsStringSearchParams: SearchParamsAsString | SearchParams
205238
): Promise<SearchResponse> {
206239
const path = '/1/indexes/{indexName}/query'.replace(
207240
'{' + 'indexName' + '}',
@@ -214,16 +247,67 @@ export class SearchApi {
214247
throw new Error('Required parameter indexName was null or undefined when calling search.');
215248
}
216249

217-
if (searchParamsSearchParamsString === null || searchParamsSearchParamsString === undefined) {
250+
if (
251+
searchParamsAsStringSearchParams === null ||
252+
searchParamsAsStringSearchParams === undefined
253+
) {
218254
throw new Error(
219-
'Required parameter searchParamsSearchParamsString was null or undefined when calling search.'
255+
'Required parameter searchParamsAsStringSearchParams was null or undefined when calling search.'
220256
);
221257
}
222258

223259
const request: Request = {
224260
method: 'POST',
225261
path,
226-
data: searchParamsSearchParamsString,
262+
data: searchParamsAsStringSearchParams,
263+
};
264+
265+
const requestOptions: RequestOptions = {
266+
headers,
267+
queryParameters,
268+
};
269+
270+
return this.sendRequest(request, requestOptions);
271+
}
272+
/**
273+
*
274+
* @summary Update settings of a given indexName. Only specified settings are overridden; unspecified settings are left unchanged. Specifying null for a setting resets it to its default value.
275+
* @param indexName The index in which to perform the request
276+
* @param indexSettings
277+
* @param forwardToReplicas When true, changes are also propagated to replicas of the given indexName.
278+
*/
279+
public async setSettings(
280+
indexName: string,
281+
indexSettings: IndexSettings,
282+
forwardToReplicas?: boolean
283+
): Promise<SetSettingsResponse> {
284+
const path = '/1/indexes/{indexName}/settings'.replace(
285+
'{' + 'indexName' + '}',
286+
encodeURIComponent(String(indexName))
287+
);
288+
let headers: Headers = { Accept: 'application/json' };
289+
let queryParameters: Record<string, string> = {};
290+
291+
if (indexName === null || indexName === undefined) {
292+
throw new Error(
293+
'Required parameter indexName was null or undefined when calling setSettings.'
294+
);
295+
}
296+
297+
if (indexSettings === null || indexSettings === undefined) {
298+
throw new Error(
299+
'Required parameter indexSettings was null or undefined when calling setSettings.'
300+
);
301+
}
302+
303+
if (forwardToReplicas !== undefined) {
304+
queryParameters['forwardToReplicas'] = forwardToReplicas.toString();
305+
}
306+
307+
const request: Request = {
308+
method: 'PUT',
309+
path,
310+
data: indexSettings,
227311
};
228312

229313
const requestOptions: RequestOptions = {

clients/algoliasearch-client-javascript/git_push.sh

Lines changed: 0 additions & 58 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
export type BaseIndexSettings = {
2+
/**
3+
* Creates replicas, exact copies of an index.
4+
*/
5+
replicas?: Array<string>;
6+
/**
7+
* Set the maximum number of hits accessible via pagination.
8+
*/
9+
paginationLimitedTo?: number;
10+
/**
11+
* A list of words for which you want to turn off typo tolerance.
12+
*/
13+
disableTypoToleranceOnWords?: Array<string>;
14+
/**
15+
* Specify on which attributes to apply transliteration.
16+
*/
17+
attributesToTransliterate?: Array<string>;
18+
/**
19+
* List of attributes on which to do a decomposition of camel case words.
20+
*/
21+
camelCaseAttributes?: Array<string>;
22+
/**
23+
* Specify on which attributes in your index Algolia should apply word segmentation, also known as decompounding.
24+
*/
25+
decompoundedAttributes?: { [key: string]: object };
26+
/**
27+
* Sets the languages at the index level for language-specific processing such as tokenization and normalization.
28+
*/
29+
indexLanguages?: Array<string>;
30+
/**
31+
* Whether promoted results should match the filters of the current search, except for geographic filters.
32+
*/
33+
filterPromotes?: boolean;
34+
/**
35+
* List of attributes on which you want to disable prefix matching.
36+
*/
37+
disablePrefixOnAttributes?: Array<string>;
38+
/**
39+
* Enables compression of large integer arrays.
40+
*/
41+
allowCompressionOfIntegerArray?: boolean;
42+
/**
43+
* List of numeric attributes that can be used as numerical filters.
44+
*/
45+
numericAttributesForFiltering?: Array<string>;
46+
/**
47+
* Lets you store custom data in your indices.
48+
*/
49+
userData?: { [key: string]: object };
50+
};
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
export type BaseSearchParams = {
2+
/**
3+
* The text to search in the index.
4+
*/
5+
query: string;
6+
/**
7+
* Overrides the query parameter and performs a more generic search that can be used to find \"similar\" results.
8+
*/
9+
similarQuery?: string;
10+
/**
11+
* Filter the query with numeric, facet and/or tag filters.
12+
*/
13+
filters?: string;
14+
/**
15+
* Filter hits by facet value.
16+
*/
17+
facetFilters?: Array<string>;
18+
/**
19+
* Create filters for ranking purposes, where records that match the filter are ranked higher, or lower in the case of a negative optional filter.
20+
*/
21+
optionalFilters?: Array<string>;
22+
/**
23+
* Filter on numeric attributes.
24+
*/
25+
numericFilters?: Array<string>;
26+
/**
27+
* Filter hits by tags.
28+
*/
29+
tagFilters?: Array<string>;
30+
/**
31+
* Determines how to calculate the total score for filtering.
32+
*/
33+
sumOrFiltersScores?: boolean;
34+
/**
35+
* Retrieve facets and their facet values.
36+
*/
37+
facets?: Array<string>;
38+
/**
39+
* Maximum number of facet values to return for each facet during a regular search.
40+
*/
41+
maxValuesPerFacet?: number;
42+
/**
43+
* Force faceting to be applied after de-duplication (via the Distinct setting).
44+
*/
45+
facetingAfterDistinct?: boolean;
46+
/**
47+
* Controls how facet values are fetched.
48+
*/
49+
sortFacetValuesBy?: string;
50+
/**
51+
* Specify the page to retrieve.
52+
*/
53+
page?: number;
54+
/**
55+
* Specify the offset of the first hit to return.
56+
*/
57+
offset?: number;
58+
/**
59+
* Set the number of hits to retrieve (used only with offset).
60+
*/
61+
length?: number;
62+
/**
63+
* Search for entries around a central geolocation, enabling a geo search within a circular area.
64+
*/
65+
aroundLatLng?: string;
66+
/**
67+
* Search for entries around a given location automatically computed from the requester’s IP address.
68+
*/
69+
aroundLatLngViaIP?: boolean;
70+
/**
71+
* Define the maximum radius for a geo search (in meters).
72+
*/
73+
aroundRadius?: number | string | null;
74+
/**
75+
* Precision of geo search (in meters), to add grouping by geo location to the ranking formula.
76+
*/
77+
aroundPrecision?: number;
78+
/**
79+
* Minimum radius (in meters) used for a geo search when aroundRadius is not set.
80+
*/
81+
minimumAroundRadius?: number;
82+
/**
83+
* Search inside a rectangular area (in geo coordinates).
84+
*/
85+
insideBoundingBox?: Array<number>;
86+
/**
87+
* Search inside a polygon (in geo coordinates).
88+
*/
89+
insidePolygon?: Array<number>;
90+
/**
91+
* This parameter changes the default values of certain parameters and settings that work best for a natural language query, such as ignorePlurals, removeStopWords, removeWordsIfNoResults, analyticsTags and ruleContexts. These parameters and settings work well together when the query is formatted in natural language instead of keywords, for example when your user performs a voice search.
92+
*/
93+
naturalLanguages?: Array<string>;
94+
/**
95+
* Enables contextual rules.
96+
*/
97+
ruleContexts?: Array<string>;
98+
/**
99+
* Define the impact of the Personalization feature.
100+
*/
101+
personalizationImpact?: number;
102+
/**
103+
* Associates a certain user token with the current search.
104+
*/
105+
userToken?: string;
106+
/**
107+
* Retrieve detailed ranking information.
108+
*/
109+
getRankingInfo?: boolean;
110+
/**
111+
* Enable the Click Analytics feature.
112+
*/
113+
clickAnalytics?: boolean;
114+
/**
115+
* Whether the current query will be taken into account in the Analytics.
116+
*/
117+
analytics?: boolean;
118+
/**
119+
* List of tags to apply to the query for analytics purposes.
120+
*/
121+
analyticsTags?: Array<string>;
122+
/**
123+
* Whether to include or exclude a query from the processing-time percentile computation.
124+
*/
125+
percentileComputation?: boolean;
126+
/**
127+
* Whether this search should participate in running AB tests.
128+
*/
129+
enableABTest?: boolean;
130+
/**
131+
* Whether this search should use AI Re-Ranking.
132+
*/
133+
enableReRanking?: boolean;
134+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { BaseIndexSettings } from './baseIndexSettings';
2+
import { IndexSettingsAsSearchParams } from './indexSettingsAsSearchParams';
3+
4+
export type IndexSettings = BaseIndexSettings & IndexSettingsAsSearchParams;

0 commit comments

Comments
 (0)