Skip to content

Commit

Permalink
feat(specs): add settings spec (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts authored Nov 30, 2021
1 parent 8997381 commit 47f71b9
Show file tree
Hide file tree
Showing 32 changed files with 971 additions and 797 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ yarn-error.log
**/node_modules
**/dist
**/.openapi-generator-ignore
**/git_push.sh
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
96 changes: 90 additions & 6 deletions clients/algoliasearch-client-javascript/client-search/searchApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import { Requester } from '../utils/requester/Requester';
import { BatchObject } from '../model/batchObject';
import { BatchResponse } from '../model/batchResponse';
import { ErrorBase } from '../model/errorBase';
import { IndexSettings } from '../model/indexSettings';
import { MultipleQueriesObject } from '../model/multipleQueriesObject';
import { MultipleQueriesResponse } from '../model/multipleQueriesResponse';
import { SaveObjectResponse } from '../model/saveObjectResponse';
import { SearchParams } from '../model/searchParams';
import { SearchParamsString } from '../model/searchParamsString';
import { SearchParamsAsString } from '../model/searchParamsAsString';
import { SearchResponse } from '../model/searchResponse';
import { SetSettingsResponse } from '../model/setSettingsResponse';
import { ApiKeyAuth } from '../model/models';

export enum SearchApiApiKeys {
Expand Down Expand Up @@ -120,6 +122,37 @@ export class SearchApi {

return this.sendRequest(request, requestOptions);
}
/**
*
* @summary Retrieve settings of a given indexName.
* @param indexName The index in which to perform the request
*/
public async getSettings(indexName: string): Promise<IndexSettings> {
const path = '/1/indexes/{indexName}/settings'.replace(
'{' + 'indexName' + '}',
encodeURIComponent(String(indexName))
);
let headers: Headers = { Accept: 'application/json' };
let queryParameters: Record<string, string> = {};

if (indexName === null || indexName === undefined) {
throw new Error(
'Required parameter indexName was null or undefined when calling getSettings.'
);
}

const request: Request = {
method: 'GET',
path,
};

const requestOptions: RequestOptions = {
headers,
queryParameters,
};

return this.sendRequest(request, requestOptions);
}
/**
*
* @summary Get search results for the given requests.
Expand Down Expand Up @@ -197,11 +230,11 @@ export class SearchApi {
*
* @summary Get search results
* @param indexName The index in which to perform the request
* @param searchParamsSearchParamsString
* @param searchParamsAsStringSearchParams
*/
public async search(
indexName: string,
searchParamsSearchParamsString: SearchParams | SearchParamsString
searchParamsAsStringSearchParams: SearchParamsAsString | SearchParams
): Promise<SearchResponse> {
const path = '/1/indexes/{indexName}/query'.replace(
'{' + 'indexName' + '}',
Expand All @@ -214,16 +247,67 @@ export class SearchApi {
throw new Error('Required parameter indexName was null or undefined when calling search.');
}

if (searchParamsSearchParamsString === null || searchParamsSearchParamsString === undefined) {
if (
searchParamsAsStringSearchParams === null ||
searchParamsAsStringSearchParams === undefined
) {
throw new Error(
'Required parameter searchParamsSearchParamsString was null or undefined when calling search.'
'Required parameter searchParamsAsStringSearchParams was null or undefined when calling search.'
);
}

const request: Request = {
method: 'POST',
path,
data: searchParamsSearchParamsString,
data: searchParamsAsStringSearchParams,
};

const requestOptions: RequestOptions = {
headers,
queryParameters,
};

return this.sendRequest(request, requestOptions);
}
/**
*
* @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.
* @param indexName The index in which to perform the request
* @param indexSettings
* @param forwardToReplicas When true, changes are also propagated to replicas of the given indexName.
*/
public async setSettings(
indexName: string,
indexSettings: IndexSettings,
forwardToReplicas?: boolean
): Promise<SetSettingsResponse> {
const path = '/1/indexes/{indexName}/settings'.replace(
'{' + 'indexName' + '}',
encodeURIComponent(String(indexName))
);
let headers: Headers = { Accept: 'application/json' };
let queryParameters: Record<string, string> = {};

if (indexName === null || indexName === undefined) {
throw new Error(
'Required parameter indexName was null or undefined when calling setSettings.'
);
}

if (indexSettings === null || indexSettings === undefined) {
throw new Error(
'Required parameter indexSettings was null or undefined when calling setSettings.'
);
}

if (forwardToReplicas !== undefined) {
queryParameters['forwardToReplicas'] = forwardToReplicas.toString();
}

const request: Request = {
method: 'PUT',
path,
data: indexSettings,
};

const requestOptions: RequestOptions = {
Expand Down
58 changes: 0 additions & 58 deletions clients/algoliasearch-client-javascript/git_push.sh

This file was deleted.

50 changes: 50 additions & 0 deletions clients/algoliasearch-client-javascript/model/baseIndexSettings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
export type BaseIndexSettings = {
/**
* Creates replicas, exact copies of an index.
*/
replicas?: Array<string>;
/**
* Set the maximum number of hits accessible via pagination.
*/
paginationLimitedTo?: number;
/**
* A list of words for which you want to turn off typo tolerance.
*/
disableTypoToleranceOnWords?: Array<string>;
/**
* Specify on which attributes to apply transliteration.
*/
attributesToTransliterate?: Array<string>;
/**
* List of attributes on which to do a decomposition of camel case words.
*/
camelCaseAttributes?: Array<string>;
/**
* Specify on which attributes in your index Algolia should apply word segmentation, also known as decompounding.
*/
decompoundedAttributes?: { [key: string]: object };
/**
* Sets the languages at the index level for language-specific processing such as tokenization and normalization.
*/
indexLanguages?: Array<string>;
/**
* Whether promoted results should match the filters of the current search, except for geographic filters.
*/
filterPromotes?: boolean;
/**
* List of attributes on which you want to disable prefix matching.
*/
disablePrefixOnAttributes?: Array<string>;
/**
* Enables compression of large integer arrays.
*/
allowCompressionOfIntegerArray?: boolean;
/**
* List of numeric attributes that can be used as numerical filters.
*/
numericAttributesForFiltering?: Array<string>;
/**
* Lets you store custom data in your indices.
*/
userData?: { [key: string]: object };
};
134 changes: 134 additions & 0 deletions clients/algoliasearch-client-javascript/model/baseSearchParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
export type BaseSearchParams = {
/**
* The text to search in the index.
*/
query: string;
/**
* Overrides the query parameter and performs a more generic search that can be used to find \"similar\" results.
*/
similarQuery?: string;
/**
* Filter the query with numeric, facet and/or tag filters.
*/
filters?: string;
/**
* Filter hits by facet value.
*/
facetFilters?: Array<string>;
/**
* Create filters for ranking purposes, where records that match the filter are ranked higher, or lower in the case of a negative optional filter.
*/
optionalFilters?: Array<string>;
/**
* Filter on numeric attributes.
*/
numericFilters?: Array<string>;
/**
* Filter hits by tags.
*/
tagFilters?: Array<string>;
/**
* Determines how to calculate the total score for filtering.
*/
sumOrFiltersScores?: boolean;
/**
* Retrieve facets and their facet values.
*/
facets?: Array<string>;
/**
* Maximum number of facet values to return for each facet during a regular search.
*/
maxValuesPerFacet?: number;
/**
* Force faceting to be applied after de-duplication (via the Distinct setting).
*/
facetingAfterDistinct?: boolean;
/**
* Controls how facet values are fetched.
*/
sortFacetValuesBy?: string;
/**
* Specify the page to retrieve.
*/
page?: number;
/**
* Specify the offset of the first hit to return.
*/
offset?: number;
/**
* Set the number of hits to retrieve (used only with offset).
*/
length?: number;
/**
* Search for entries around a central geolocation, enabling a geo search within a circular area.
*/
aroundLatLng?: string;
/**
* Search for entries around a given location automatically computed from the requester’s IP address.
*/
aroundLatLngViaIP?: boolean;
/**
* Define the maximum radius for a geo search (in meters).
*/
aroundRadius?: number | string | null;
/**
* Precision of geo search (in meters), to add grouping by geo location to the ranking formula.
*/
aroundPrecision?: number;
/**
* Minimum radius (in meters) used for a geo search when aroundRadius is not set.
*/
minimumAroundRadius?: number;
/**
* Search inside a rectangular area (in geo coordinates).
*/
insideBoundingBox?: Array<number>;
/**
* Search inside a polygon (in geo coordinates).
*/
insidePolygon?: Array<number>;
/**
* 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.
*/
naturalLanguages?: Array<string>;
/**
* Enables contextual rules.
*/
ruleContexts?: Array<string>;
/**
* Define the impact of the Personalization feature.
*/
personalizationImpact?: number;
/**
* Associates a certain user token with the current search.
*/
userToken?: string;
/**
* Retrieve detailed ranking information.
*/
getRankingInfo?: boolean;
/**
* Enable the Click Analytics feature.
*/
clickAnalytics?: boolean;
/**
* Whether the current query will be taken into account in the Analytics.
*/
analytics?: boolean;
/**
* List of tags to apply to the query for analytics purposes.
*/
analyticsTags?: Array<string>;
/**
* Whether to include or exclude a query from the processing-time percentile computation.
*/
percentileComputation?: boolean;
/**
* Whether this search should participate in running AB tests.
*/
enableABTest?: boolean;
/**
* Whether this search should use AI Re-Ranking.
*/
enableReRanking?: boolean;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { BaseIndexSettings } from './baseIndexSettings';
import { IndexSettingsAsSearchParams } from './indexSettingsAsSearchParams';

export type IndexSettings = BaseIndexSettings & IndexSettingsAsSearchParams;
Loading

0 comments on commit 47f71b9

Please sign in to comment.