MCPcopy Create free account
hub / github.com/ember-learn/ember-api-docs / AlgoliaService

Class AlgoliaService

app/services/algolia.js:5–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3import config from 'ember-api-docs/config/environment';
4
5export default class AlgoliaService extends Service {
6 async search(query, params) {
7 if (query) {
8 if (Array.isArray(query) && !params) {
9 // if multiple indices
10 return this._client.search(query);
11 } else if (!params) {
12 // if no params
13 return this.accessIndex(query.indexName).search(query.query);
14 } else {
15 // if params and callback
16 return this.accessIndex(query.indexName).search(query.query, params);
17 }
18 }
19 }
20
21 accessIndex(IndexName) {
22 if (!this._indices[IndexName]) {
23 this._indices[IndexName] = this._client.initIndex(IndexName);
24 }
25 return this._indices[IndexName];
26 }
27
28 constructor() {
29 super(...arguments);
30 this._client = algoliasearch(
31 config.algolia.algoliaId,
32 config.algolia.algoliaKey,
33 );
34 this._indices = {};
35 }
36}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected