Sajari integrates with Drupal via the Search API module, making it easy to add advanced search and discovery capabilities to any drupal site in minutes.
Although Drupal sites can be indexed with the Crawler, the Search API enables instant indexing of changes made in Drupal and provides more control over what fields are being indexed.
Note that Sajari Search API module only implements the index syncing components of the module. To integrate a search frontend, we recommend using the Sajari React SDK.
Enter the following command in the terminal at the root of your site:
composer update drupal/search_api_sajari
Composer will install the Search API Sajari module along with the required dependencies. Once installed, you'll need to ensure the module has been enabled. Go to http://your-drupal-domain.com/en/admin/modules (replace your-drupal-domain.com with your ) and locate the Search API Sajari module in the Search section. Enable the module if it's not already enable.
Adding your Sajari account
Although not strictly a "Server", click Add server to add your Sajari account. If you don't have an account yet, head over to http://sajari.com and sign up before you continue.
- Click Add server.
- Provide a Server name, we recommend to keep it simple and call it Sajari.
- Ensure the Enabled checkbox is checked.
- Specify the Base URL. This is the base url of your drupal site (eg. http://your-drupal-domain.com).
- Enter the Key ID and secret from your Sajari credentials page.
- Enter the Collection ID to use. If no collection exists with this name, the collection will be created for you.
- Save your server settings.
Adding the index
Now that the connection to your Sajari account is set up, you will need to specify which fields to index.
- Click Add index.
- Specify an Index name (eg. content-index).
- Specify the Datasources, the Drupal entities you want to store in this index.
- (Optional) Configure the data sources
- Ensure you select Sajari (if this is the name you chose for the Server) as the Server. This ensures the entities will be stored in the Sajari index.
- Save your index settings.
Once you save your index settings, you will be asked to specify the fields you want to index.
- Click Add on the fields you want to use for search or as filters.
- Click Done.
Once you've added the fields, you will be asked to configure the data types. The Sajari Search API module will do it's best to automatically detect the data type (eg. String or Integer), but we recommend to double check the configuration. In additional to the data type, there are a few other options that can be configured for each field.
- Sajari Array - If the represents a list, for example a list of tags, ensure this option is selected.
- Sajari Indexed - Select this option if this field should be searchable.
- Sajari Autocomplete - Use this field to train the autocomplete suggestions in Sajari. Generally you want to restrict this to shorter fields such as titles, topics, categories etc.
- Sajari Mode - Select if the field should be Optional, Required or Unique. Records that don't meet the criteria selected are rejected during the indexing process.
Once all fields are configured click Save changes at the bottom of the page.
Generally indexing happens automatically, but you can review the status of your index in the View tab. This view also provides a number of useful functions.
- Index now - to trigger the indexing of items in the queue
- Queue all items for reindexing - this is useful when adding additional fields to the index. Unless all records are reindexed, the data from the new field will not be available in the index.
- Clear all indexed data - use this when you remove content types to ensure they are deleted from the index.
- Rebuilt tracking information - The complete information about existing and indexed items for this index will be deleted and rebuilt.
When an indexed content type in Drupal changes, the changes will automatically be queued and indexed. This process happens almost instantly. To verify whether content has been successfully indexed, use the Preview in Sajari.