Skip to content

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.

  1. Connect Drupal with Quant
  2. Enable Quant search in Dashboard
  3. Add the quantcdn project to your site, e.g. composer require 'drupal/quantcdn:^2.3' (Drupal 11). quant_search also needs the Token module
  4. Enable the quant_search Drupal module (drush en quant_search, or tick Quant Search on Extend (/admin/modules) and click Install)
  5. Go to the Drupal Quant Search admin page (/admin/config/development/quant/search)
  6. You should see a Search is enabled for *project* message

From module 2.3.0, one screen creates a working search page:

  1. Go to the Drupal Quant Search Pages admin page (/admin/config/development/quant/search/pages)
  2. Click Create a search page
  3. 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
  4. 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
  5. Choose the filters shown beside the results. The module proposes Content type and one filter for each vocabulary that the chosen content types reference (for example Topics (used by Article, Event)), plus Language on a multilingual site
  6. Choose the filter style and the number of results per page
  7. Leave Add a search box with suggestions to every page checked to place the autocomplete block in a region of your theme. From module 2.3.1 the Region field suggests a region and names it. The suggestion is secondary_menu (Olivero and themes based on it), then the region where the theme shows the Drupal search box, then header. The choice appears only when the Block module is installed. If the theme already has a Quant search box, the option starts unchecked
  8. Click Create the search page. The page is saved, enabled, its filters are registered with Quant, and it is published
  9. If you placed a search box, publish the site again (Seed, then Save 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.

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:

  1. On the search pages admin page, click Create from a View
  2. Choose the View page, for example News: /news, and click Propose a search page
  3. Review the proposal on the Create a search page screen, then click Create 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.

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.

  1. Go to the Drupal Quant Search Pages admin page (/admin/config/development/quant/search/pages)
  2. Click the Add a search page (all settings) button (Add Quant search page before 2.3.0)
  3. Fill in the page details including, at minimum, Label and Route
  4. The page can be enabled or disabled as needed and defaults to disabled
  5. The options are fairly self-explanatory, but some notable options are detailed below
  6. Click the Save button to save the search page and send the page to Quant

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 go to the search engine as written, so use the syntax of your platform’s engine:

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).

Search facets can be added and will allow the user to filter the content.

  1. There are 3 facet styles: checkbox, select, and menu
  2. The Content type and Language facets have no additional configuration
  3. The Taxonomy facet requires you to select a Vocabulary
  4. The Facet heading is optional, but good for UX and accessibility
  5. For multilingual sites, the Facet language can be chosen
  6. To remove any facet, click the Remove facet button
  7. To add a facet, fill in the bottom facet details and click the Add facet button
  8. Facets can be reordered using drag-and-drop or by changing the Facet weight
  9. After changing any facet information, click the Save button

The Quant Search index contains all the information sent to Quant based on the entity configuration and search pages.

  1. Go to the Drupal Quant Search admin page for index status (/admin/config/development/quant/search)
  2. Click the Clear index button to remove all the content from the search index
  3. Go to the Drupal Quant Index admin page to reindex content (/admin/config/development/quant/search/index)

Some of the search results details are configurable such as the result title, summary, image, and view mode.

  1. Go to the Drupal Quant Entity configuration admin page (/admin/config/development/quant/search/entities)
  2. The configuration defaults to common search requirements
  3. Enable or disable node (page) and term content with the checkboxes
  4. No other configuration is currently available for taxonomy
  5. Click the Save configuration button to save changes

Search content for nodes (pages) can be configured per content type.

  • There are default options for Title, Summary, Image, and Content 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

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]