Using the Drupal Quant Search module
The optional Drupal Quant Search (quant_search) submodule creates Quant search pages in Drupal. Drupal renders each search page and publishes it to Quant like any other page, and the page searches your Quant search index from the browser. On QuantCDN the index runs on Algolia; on QuantGov it runs on Typesense in Australia (https://search.quantgov.cloud). The module picks the right one for your project, so the setup is the same on both platforms.
- Connect Drupal with Quant
- Enable Quant search in Dashboard
- Add the
quantcdnproject to your site, e.g.composer require 'drupal/quantcdn:^2.3'(Drupal 11).quant_searchalso needs the Token module - Enable the
quant_searchDrupal module (drush en quant_search, or tick Quant Search on Extend (/admin/modules) and click Install) - Go to the Drupal Quant Search admin page (
/admin/config/development/quant/search) - You should see a
Search is enabled for *project*message
Create a search page
Section titled “Create a search page”From module 2.3.0, one screen creates a working search page:
- Go to the Drupal Quant Search Pages admin page (
/admin/config/development/quant/search/pages) - Click
Create a search page - Check the proposed address. It is
search, or the first free address (site-search,search-2, …) when Drupal already has a page at/search, for example a View - Choose the content types to search. A content type that is not in the search index yet is added to the index settings, and the page asks you to re-index
- Choose the filters shown beside the results. The module proposes
Content typeand one filter for each vocabulary that the chosen content types reference (for exampleTopics (used by Article, Event)), plusLanguageon a multilingual site - Choose the filter style and the number of results per page
- Leave
Add a search box with suggestions to every pagechecked to place the autocomplete block in a region of your theme. From module 2.3.1 theRegionfield suggests a region and names it. The suggestion issecondary_menu(Olivero and themes based on it), then the region where the theme shows the Drupal search box, thenheader. The choice appears only when the Block module is installed. If the theme already has a Quant search box, the option starts unchecked - Click
Create the search page. The page is saved, enabled, its filters are registered with Quant, and it is published - If you placed a search box, publish the site again (
Seed, thenSave and Queue). The static pages show the box only after they are published again
You can change everything later in the full search page form.
Create a search page from a View
Section titled “Create a search page from a View”A static site cannot run a View with exposed filters. From module 2.3.0 you can turn a View page into a Quant search page:
- On the search pages admin page, click
Create from a View - Choose the View page, for example
News: /news, and clickPropose a search page - Review the proposal on the
Create a search pagescreen, then clickCreate the search page
The proposal takes from the View:
| In the View | In the search page |
|---|---|
| A fixed content type filter | The content types to search |
| An exposed content type, language or taxonomy filter | A filter (facet) beside the results |
| A fixed taxonomy term filter | A manual filter on the term names, in your engine’s syntax |
| An exposed keyword filter (for example “Combine fields”) | The keyword box |
| The pager | Results per page |
The search index holds the title, summary, content, content type, language and taxonomy term names of each page, so other View settings cannot be converted. The proposal lists each one, for example an exposed filter on a list or date field, a date condition such as “upcoming events only”, the sort order (Quant orders results by relevance) and contextual filters. The View stays at its address; to give that address to the search page, disable the View page first, then edit the search page.
Search Pages
Section titled “Search Pages”Unlimited Quant search pages can be added in Drupal. They are pushed to Quant automatically when creating or updating search pages.
From module 2.3.1, a search page publishes every time it is saved, also when the save comes from Drush, a recipe, custom code or a configuration import (drush cim). The publish runs at the end of the request, after an import is complete, and only when Quant is enabled (quant.settings:quant_enabled) and the site is connected. A change saved during installation or in maintenance mode is not published then. Drupal lists it with the changes that did not reach Quant, and the next save of the page or a seed publishes it. A Quant error during the publish is logged and listed with the other failed pushes. It does not stop the save or the import. Pages saved before the upgrade are not published again: save them or seed.
When you disable or delete a search page, Quant unpublishes it. When a page gets a new address, Quant unpublishes the old address and redirects it (301) to the new one, unless another search page uses the old address now. A change of case only (/Search to /search) is not a move.
A site that shares its configuration with another site publishes to its own project only. Turn quant_enabled off on a copy that must not publish.
Two search pages cannot have the same address. The form refuses an address that another search page uses, also when only the case differs, because Quant paths do not depend on case.
- Go to the Drupal Quant Search Pages admin page (
/admin/config/development/quant/search/pages) - Click the
Add a search page (all settings)button (Add Quant search pagebefore 2.3.0) - Fill in the page details including, at minimum,
LabelandRoute - The page can be enabled or disabled as needed and defaults to disabled
- The options are fairly self-explanatory, but some notable options are detailed below
- Click the
Savebutton to save the search page and send the page to Quant
Styles
Section titled “Styles”From module 2.3.1, the default search page and search box styles follow the site theme. They inherit the theme’s fonts, colours and links. A theme can adjust them with --quant-search-* CSS custom properties. The list is in quant_search.algolia.css. On narrow screens the filters fold behind a Filter results toggle. A theme that overrides search-page.html.twig keeps its own copy.
Manual filters
Section titled “Manual filters”Manual filters go to the search engine as written, so use the syntax of your platform’s engine:
- QuantCDN uses the Algolia filter syntax, for example
topic_en:'Water quality' AND content_type:'article'. - QuantGov uses the Typesense filter syntax, for example
topic_en:=`Water quality` && content_type:=`article`.
A search page created from a View writes its fixed term filter in the syntax of your project’s engine.
The index keys are content_type, content_type_{langcode}, language_{langcode} and, for taxonomy terms, {vocabulary}_{langcode} (for example topic_en for the topic vocabulary in English).
Facets
Section titled “Facets”Search facets can be added and will allow the user to filter the content.
- There are 3 facet styles: checkbox, select, and menu
- The
Content typeandLanguagefacets have no additional configuration - The
Taxonomyfacet requires you to select aVocabulary - The
Facet headingis optional, but good for UX and accessibility - For multilingual sites, the
Facet languagecan be chosen - To remove any facet, click the
Remove facetbutton - To add a facet, fill in the bottom facet details and click the
Add facetbutton - Facets can be reordered using drag-and-drop or by changing the
Facet weight - After changing any facet information, click the
Savebutton
Search Index
Section titled “Search Index”The Quant Search index contains all the information sent to Quant based on the entity configuration and search pages.
- Go to the Drupal Quant Search admin page for index status (
/admin/config/development/quant/search) - Click the
Clear indexbutton to remove all the content from the search index - Go to the Drupal Quant Index admin page to reindex content (
/admin/config/development/quant/search/index)
Entity Configuration
Section titled “Entity Configuration”Some of the search results details are configurable such as the result title, summary, image, and view mode.
- Go to the Drupal Quant
Entity configurationadmin page (/admin/config/development/quant/search/entities) - The configuration defaults to common search requirements
- Enable or disable
node(page) andtermcontent with the checkboxes - No other configuration is currently available for taxonomy
- Click the
Save configurationbutton to save changes
Node Configuration
Section titled “Node Configuration”Search content for nodes (pages) can be configured per content type.
- There are default options for
Title,Summary,Image, andContent view mode - For each content type, there are overrides available for these options
- Content types can also be excluded from the search index entirely
- Reindex content if the configuration has changed
Images
Section titled “Images”To show images in the search results, update the image token to the correct image style for your content type. Example:
[node:field_image:medium:url]