Skip to content

Commit 44f257e

Browse files
arturfracalaArtur Fracala
andauthored
ensure api method names with underscores are indexed correctly in Alg… (#1523)
ensure api method names with underscores are indexed correctly in Algolia Co-authored-by: Artur Fracala <[email protected]>
1 parent 91ef6d1 commit 44f257e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/components/core/Search/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,24 @@ const transformHits = (hits) => {
4040
return updatedHits;
4141
};
4242

43+
const transformSearchClient = (searchClient) => ({
44+
...searchClient,
45+
search(requests) {
46+
if (requests[0] && requests[0] && requests[0].query) {
47+
requests[0].query = requests[0].query.replace(/_/g, " ");
48+
}
49+
return searchClient.search(requests);
50+
},
51+
});
52+
4353
const Search = () => (
4454
<DocSearch
4555
apiKey={process.env.NEXT_PUBLIC_ALGOLIA_API_KEY}
4656
appId={process.env.NEXT_PUBLIC_ALGOLIA_APP_ID}
4757
indexName={"livechatinc"}
4858
searchParameters={{ hitsPerPage: 7 }}
4959
transformItems={transformHits}
60+
transformSearchClient={transformSearchClient}
5061
/>
5162
);
5263

0 commit comments

Comments
 (0)