- Silverstripe 4+
- NPM
composer require chewyou/silverstripe-algolia-search
You may need to add the repository to the composer.json file, as below:
"repositories":
[
{
"type": "vcs",
"url": "https://github.com/chewyou/silverstripe-algolia-search.git"
}
],
To include the Algolia Search JS files:
npm install algoliasearch jquery --save
Add the following to all the page types you need indexed. Put on a base page to encompass all child pages.
private static $enable_indexer = true;
Under Settings > Algolia Search Configuration, enter your Algolia account details.
- Admin API Key
- Search API Key
- Application ID
- Index Name
Copy the directory /algolia-search to your theme /src/js/components directory. Line 32 of AlgoliaController.php looks for this file.
Refer to /theme/src/js/main.js for inspiration (ES6 is used) Note the search-config.js (especially) and search-algolia.js files shouldn't be touched.
search-action.js however should be adjusted based on the values indexed and result layout
<% include AlgoliaSearchResults %>
This is an example/guide to go with the JS and should also be overridden with your own implementation
Run the dev task Algolia: Index Page by Type where:
- PageType is the classname of the page
- Values are comma separated, no spaces, case sensitive and are $db values (ie. &values=Title,Content,LastEdited)
Or go through and save/publish all of the pages to index /dev/tasks/AlgoliaIndexPageByType&pagetype={PageType}&values={Title,Content,LastEdited}
Update this project to only use ElementalBlocks