Skip to content

Commit

Permalink
Adds the getObject method to Algolia service (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffdaley authored Jul 18, 2023
1 parent 03a976f commit 295e045
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions web/app/services/algolia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,20 @@ export default class AlgoliaService extends Service {
return facetFilters;
}

/**
* Returns an object for a given ID and an optional indexName.
* If no match is found, an error is returned.
* Used by the `RelatedResources` component to find docs from first-party URLs.
*
* https://www.algolia.com/doc/api-reference/api-methods/get-objects/
*/
getObject = restartableTask(
async (objectID: string, indexName?: string): Promise<unknown> => {
const index = indexName ? this.client.initIndex(indexName) : this.index;
return await index.getObject(objectID);
}
);

/**
* Returns a search response for a given query and params.
* Restarts with every search input keystroke.
Expand Down

0 comments on commit 295e045

Please sign in to comment.