Skip to content

Commit a8af9b1

Browse files
authored
feat: Added synonyms endpoints for the search client (#30)
1 parent a13203b commit a8af9b1

28 files changed

+1041
-13
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export type ClearAllSynonymsResponse = {
2+
/**
3+
* TaskID of the indexing task to wait for.
4+
*/
5+
taskID: number;
6+
/**
7+
* Date of last update (ISO-8601 format).
8+
*/
9+
updatedAt: Date;
10+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export type DeleteSynonymResponse = {
2+
/**
3+
* TaskID of the indexing task to wait for.
4+
*/
5+
taskID: number;
6+
/**
7+
* Date of deletion (ISO-8601 format).
8+
*/
9+
deletedAt: Date;
10+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export type HighlightedSynonym = {
2+
/**
3+
* Markup text with occurrences highlighted.
4+
*/
5+
value?: string;
6+
/**
7+
* Indicates how well the attribute matched the search query.
8+
*/
9+
matchLevel?: HighlightedSynonym.MatchLevelEnum;
10+
/**
11+
* List of words from the query that matched the object.
12+
*/
13+
matchedWords?: string[];
14+
/**
15+
* Whether the entire attribute value is highlighted.
16+
*/
17+
fullyHighlighted?: boolean;
18+
};
19+
20+
export namespace HighlightedSynonym {
21+
export enum MatchLevelEnum {
22+
None = 'none',
23+
Partial = 'partial',
24+
Full = 'full',
25+
}
26+
}

clients/algoliasearch-client-javascript/client-search/model/models.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ export * from './baseSearchResponse';
77
export * from './baseSearchResponseFacetsStats';
88
export * from './batchObject';
99
export * from './batchResponse';
10+
export * from './clearAllSynonymsResponse';
1011
export * from './deleteIndexResponse';
12+
export * from './deleteSynonymResponse';
1113
export * from './errorBase';
1214
export * from './highlightResult';
1315
export * from './index';
@@ -24,12 +26,17 @@ export * from './rankingInfo';
2426
export * from './rankingInfoMatchedGeoLocation';
2527
export * from './record';
2628
export * from './saveObjectResponse';
29+
export * from './saveSynonymResponse';
30+
export * from './saveSynonymsResponse';
2731
export * from './searchHits';
2832
export * from './searchParams';
2933
export * from './searchParamsAsString';
3034
export * from './searchResponse';
35+
export * from './searchSynonymsResponse';
3136
export * from './setSettingsResponse';
3237
export * from './snippetResult';
38+
export * from './synonymHit';
39+
export * from './synonymHitHighlightResult';
3340

3441
export interface Authentication {
3542
/**
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export type SaveSynonymResponse = {
2+
/**
3+
* TaskID of the indexing task to wait for.
4+
*/
5+
taskID: number;
6+
/**
7+
* Date of last update (ISO-8601 format).
8+
*/
9+
updatedAt: Date;
10+
/**
11+
* ObjectID of the inserted object.
12+
*/
13+
id: string;
14+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export type SaveSynonymsResponse = {
2+
/**
3+
* TaskID of the indexing task to wait for.
4+
*/
5+
taskID: number;
6+
/**
7+
* Date of last update (ISO-8601 format).
8+
*/
9+
updatedAt: Date;
10+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type { SynonymHit } from './synonymHit';
2+
3+
export type SearchSynonymsResponse = {
4+
/**
5+
* Array of synonym objects.
6+
*/
7+
hits: SynonymHit[];
8+
/**
9+
* Number of hits that the search query matched.
10+
*/
11+
nbHits: number;
12+
};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import type { SynonymHitHighlightResult } from './synonymHitHighlightResult';
2+
3+
/**
4+
* Synonym object.
5+
*/
6+
export type SynonymHit = {
7+
/**
8+
* Unique identifier of the synonym object to be created or updated.
9+
*/
10+
objectID: string;
11+
/**
12+
* Type of the synonym object.
13+
*/
14+
type: SynonymHit.TypeEnum;
15+
/**
16+
* Words or phrases to be considered equivalent.
17+
*/
18+
synonyms?: string[];
19+
/**
20+
* Word or phrase to appear in query strings (for onewaysynonym).
21+
*/
22+
input?: string;
23+
/**
24+
* Word or phrase to appear in query strings (for altcorrection1 and altcorrection2).
25+
*/
26+
word?: string;
27+
/**
28+
* Words to be matched in records.
29+
*/
30+
corrections?: string[];
31+
/**
32+
* Token to be put inside records.
33+
*/
34+
placeholder?: string;
35+
/**
36+
* List of query words that will match the token.
37+
*/
38+
replacements?: string[];
39+
_highlightResult?: SynonymHitHighlightResult;
40+
};
41+
42+
export namespace SynonymHit {
43+
export enum TypeEnum {
44+
Synonym = 'synonym',
45+
Onewaysynonym = 'onewaysynonym',
46+
Altcorrection1 = 'altcorrection1',
47+
Altcorrection2 = 'altcorrection2',
48+
Placeholder = 'placeholder',
49+
}
50+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { HighlightResult } from './highlightResult';
2+
3+
/**
4+
* Highlighted results.
5+
*/
6+
export type SynonymHitHighlightResult = {
7+
type?: HighlightResult;
8+
synonyms?: HighlightResult[];
9+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Type of the synonym object.
3+
*/
4+
export enum SynonymType {
5+
Synonym = 'synonym',
6+
Onewaysynonym = 'onewaysynonym',
7+
Altcorrection1 = 'altcorrection1',
8+
Altcorrection2 = 'altcorrection2',
9+
Placeholder = 'placeholder',
10+
}

0 commit comments

Comments
 (0)