forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalgolia.js
More file actions
34 lines (31 loc) · 777 Bytes
/
algolia.js
File metadata and controls
34 lines (31 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import algoliasearch from 'algoliasearch/lite';
import {
ALGOLIA_API_KEY,
ALGOLIA_APPLICATION_ID,
ALGOLIA_DEFAULT_INDEX,
} from '@codesandbox/common/lib/utils/config';
const client = algoliasearch(ALGOLIA_APPLICATION_ID, ALGOLIA_API_KEY);
const index = client.initIndex(ALGOLIA_DEFAULT_INDEX);
export function searchFacets({ facet, query, hitsPerPage }) {
return index.searchForFacetValues({
facetName: facet,
facetQuery: query,
maxFacetHits: hitsPerPage,
typoTolerance: 'strict',
});
}
export function search({
query,
attributesToRetrieve,
attributesToHighlight,
hitsPerPage,
searchParameters,
}) {
return index.search({
query,
attributesToRetrieve,
attributesToHighlight,
hitsPerPage,
...searchParameters,
});
}