Skip to content

Commit

Permalink
feat: Added synonyms endpoints for the search client (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
damcou authored Dec 14, 2021
1 parent a13203b commit a8af9b1
Show file tree
Hide file tree
Showing 28 changed files with 1,041 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export type ClearAllSynonymsResponse = {
/**
* TaskID of the indexing task to wait for.
*/
taskID: number;
/**
* Date of last update (ISO-8601 format).
*/
updatedAt: Date;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export type DeleteSynonymResponse = {
/**
* TaskID of the indexing task to wait for.
*/
taskID: number;
/**
* Date of deletion (ISO-8601 format).
*/
deletedAt: Date;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export type HighlightedSynonym = {
/**
* Markup text with occurrences highlighted.
*/
value?: string;
/**
* Indicates how well the attribute matched the search query.
*/
matchLevel?: HighlightedSynonym.MatchLevelEnum;
/**
* List of words from the query that matched the object.
*/
matchedWords?: string[];
/**
* Whether the entire attribute value is highlighted.
*/
fullyHighlighted?: boolean;
};

export namespace HighlightedSynonym {
export enum MatchLevelEnum {
None = 'none',
Partial = 'partial',
Full = 'full',
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ export * from './baseSearchResponse';
export * from './baseSearchResponseFacetsStats';
export * from './batchObject';
export * from './batchResponse';
export * from './clearAllSynonymsResponse';
export * from './deleteIndexResponse';
export * from './deleteSynonymResponse';
export * from './errorBase';
export * from './highlightResult';
export * from './index';
Expand All @@ -24,12 +26,17 @@ export * from './rankingInfo';
export * from './rankingInfoMatchedGeoLocation';
export * from './record';
export * from './saveObjectResponse';
export * from './saveSynonymResponse';
export * from './saveSynonymsResponse';
export * from './searchHits';
export * from './searchParams';
export * from './searchParamsAsString';
export * from './searchResponse';
export * from './searchSynonymsResponse';
export * from './setSettingsResponse';
export * from './snippetResult';
export * from './synonymHit';
export * from './synonymHitHighlightResult';

export interface Authentication {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export type SaveSynonymResponse = {
/**
* TaskID of the indexing task to wait for.
*/
taskID: number;
/**
* Date of last update (ISO-8601 format).
*/
updatedAt: Date;
/**
* ObjectID of the inserted object.
*/
id: string;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export type SaveSynonymsResponse = {
/**
* TaskID of the indexing task to wait for.
*/
taskID: number;
/**
* Date of last update (ISO-8601 format).
*/
updatedAt: Date;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { SynonymHit } from './synonymHit';

export type SearchSynonymsResponse = {
/**
* Array of synonym objects.
*/
hits: SynonymHit[];
/**
* Number of hits that the search query matched.
*/
nbHits: number;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import type { SynonymHitHighlightResult } from './synonymHitHighlightResult';

/**
* Synonym object.
*/
export type SynonymHit = {
/**
* Unique identifier of the synonym object to be created or updated.
*/
objectID: string;
/**
* Type of the synonym object.
*/
type: SynonymHit.TypeEnum;
/**
* Words or phrases to be considered equivalent.
*/
synonyms?: string[];
/**
* Word or phrase to appear in query strings (for onewaysynonym).
*/
input?: string;
/**
* Word or phrase to appear in query strings (for altcorrection1 and altcorrection2).
*/
word?: string;
/**
* Words to be matched in records.
*/
corrections?: string[];
/**
* Token to be put inside records.
*/
placeholder?: string;
/**
* List of query words that will match the token.
*/
replacements?: string[];
_highlightResult?: SynonymHitHighlightResult;
};

export namespace SynonymHit {
export enum TypeEnum {
Synonym = 'synonym',
Onewaysynonym = 'onewaysynonym',
Altcorrection1 = 'altcorrection1',
Altcorrection2 = 'altcorrection2',
Placeholder = 'placeholder',
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { HighlightResult } from './highlightResult';

/**
* Highlighted results.
*/
export type SynonymHitHighlightResult = {
type?: HighlightResult;
synonyms?: HighlightResult[];
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Type of the synonym object.
*/
export enum SynonymType {
Synonym = 'synonym',
Onewaysynonym = 'onewaysynonym',
Altcorrection1 = 'altcorrection1',
Altcorrection2 = 'altcorrection2',
Placeholder = 'placeholder',
}
Loading

0 comments on commit a8af9b1

Please sign in to comment.