While Solr compartmentalizes settings into cores, Search API organizes things into indexes. Each Search API index can have a unique set of settings and crawl a specified list of content types. Search API indexes can be created in the Search API admin interface.
In this tutorial, we'll:
- Identify a Search API index
- Describe how an index is related to a Solr core
By the end of this tutorial you should be able to create a new Search API Index connected to a Solr backend.
Creating an index alone is not enough. To populate the index, we need to specify the fields necessary to populate the index. Selecting the fields is accomplished in the Search API admin UI.
In this tutorial, we'll:
- Explain how to select what populates a search index
- Describe a field boost, and how it is used to customize results
By the end of this tutorial you should be able to add fields to a Search API Index so their content is available for searching, and then instruct Search API to index the content of your site.
Reference field types, such as taxonomy term fields, paragraph fields, or plain entity reference fields, refer to a completely separate entity within the site. This makes search configuration complicated as the typical scope of a search crawl is on a per-node (really a per-entity) basis. Fortunately there are known strategies to index these fields with ease.
In this tutorial, we'll:
- Describe why reference types pose a particular challenge to indexing
- Discuss the importance of display modes in indexing
- Highlight how the Rendered HTML Output field can be used to index paragraphs
By the end of this tutorial you should be able to add reference fields to your Search API Index and allow users to search their contents in the correct context.
One of Search API’s key advantages is that custom search pages can be created using Views. This allows a high degree of customization, while relying on a familiar toolset.
In this tutorial, we'll:
- Describe how to use Views to create a search page
- Explain search page best practices, including requiring input and no-results text
By the end of this tutorial you should be able to create a page that users can use to search your site's content using the Solr search backend.
Drupal has the ability to support multiple Search API indexes within a single installation. While adding a new index is easy, we must understand the implications of creating and using multiple Search API indexes.
In this tutorial, we'll:
- Identify when to create multiple indexes in Search API
- Define virtual indexes, and their performance implications
Processors allow you to augment your search indexes by performing additional operations before or after the index operation. This can make your search more flexible.
In this tutorial, we'll:
- Identify what a processor is, and when it can be employed in the search pipeline.
- List useful processors provided by Search API.
- Describe how to apply a processor to an index, and why reindexing is necessary.
Excerpts are brief snippets of text displayed in search results. They give context to how the search terms relate to the result. Search API provides support for excerpts out of the box.
In this tutorial, we'll:
- Identify how to apply excerpts to a search index
- Describe how to add excerpt display to the search view
By the end of this tutorial you should be able to use the Highlight search processor to add excerpts to search results.
Autocomplete provides a brief and quick list of results to the user while typing. While this functionality isn’t available out of the box, it’s easy to add using an additional contributed module, Search API Autocomplete.
In this tutorial, we'll:
- Describe how to add autocomplete functionality to an existing index
By the end of this tutorial you should be able to add an autocomplete feature to the search query text field.
One of the key advantages of custom search is to do more than provide a single, global search box. Filtering allows you to divide results to a subset.
In this tutorial, we'll:
- Describe how to configure filtering through use of a taxonomy field
- Explain the disadvantages of this approach, including how it relies on Views to reduce results rather than Solr
Filtering results allows us to divide up the result set along one or more dimensions. It’s built in to Search API, but often we need a slightly different approach. Drill-down search or faceted searching allows us to constrain (rather than divide) our result set to one or more dimensions. The contributed Facets module provides this functionality.
In this tutorial, we'll:
- Describe how facets constrains results to preconfigured dimensions
- Demonstrate how use of a facet also constrains the possible selections for other facets
- List the steps for installing Facets module
- Describe the field types best used for creating facets
By the end of this tutorial you should be able to explain what facets are and how they work in the context of searching a Drupal site's content.
Creating a facet in Drupal is rather different from using Facets API in Drupal 7. In the new module, we first create a search view, and then configure facets against target fields in the index. Once created, we must configure the facet UI to appear on target pages using the Blocks UI.
In this tutorial, we'll:
- List the steps necessary to create a facet using a non-reference field (i.e. boolean, or text list)
- Explain why facets are displayed using blocks
- Describe the various facet display modes and uses for each
By the end of this tutorial you should be able to add a facet based on a text list field and allow users to filter search results using the values in the list field.
A powerful facet combination is to create a search Facet on a taxonomy field. This brings several advantages to how your search can be configured and displayed.
In this tutorial, we'll:
- Describe the additional complexities for using a reference field for a facet
- Show how to use taxonomy weights to control facet option order
By the end of this tutorial you should be able to add a facet that allows users to filter search result based on taxonomy terms.
When running tests with PHPUnit we need to specify a phpunit.xml file that contains the configuration that we want to use. Often times (and in much of the existing documentation) the recommendation is to copy the core/phpunit.xml.dist file to core/phpunit.xml and make your changes there. And this works fine, until something like a composer install
or composer update
ends up deleting your modified file. Instead, you should copy the file to a different location in your project and commit it to your version control repository.
In this tutorial we'll:
- Learn how to move, and modify, the phpunit.xml.dist file provided by Drupal core
- Understand the benefits of doing so
- Demonstrate how to run
phpunit
with an alternative configuration file
By the end of this tutorial you should be able to commit your phpunit.xml configuration file to your project's Git repository and ensure it doesn't get accidentally deleted.
Drupal Console
FreeThe Drupal Console is a suite of tools run from a command line interface (CLI) to generate boilerplate code and interact with a Drupal installation.
Note: This project is no longer actively maintained. See the Drush topic for alternative solutions.
To follow along with our Drupal Views tutorials, set up a Drupal site loaded with our 4 custom views and baseball stats content that will make querying in Views a bit more interesting and meaningful.
By the end of this tutorial, you should choose a solution and follow the instructions for creating a Drupal site loaded with our starting point content and views.
Often, there's an existing Drush command that does most of what you want, but needs just a few tweaks or enhancements to make it meet your project requirements. Maybe the existing core Drush command has the functionality but lacks some additional validation. Or maybe you need to add an additional option to perform some application-specific debugging logic for all commands in a group.
Drush hooks can be used to alter, extend, and enhance existing Drush commands.
In this tutorial we'll:
- Learn how to alter a Drush command with code in a custom module
- Declare a validation hook that alters the
user:password
command with additional password validation logic
By the end of this tutorial you should be able to alter a Drush command provided by Drush core or a contributed module with your own custom code.
Back-end developers, and Drupal site builders, often find themselves having to perform the same UI steps over and over again, like exporting configuration, importing configuration changes, running cron, processing a large queue of jobs, indexing items for Search API, and more. Performing these tasks with Drush saves time and reduces the number of clicks required.
Drush core contains commands to execute all the most common tasks. Many contributed modules provide their own Drush commands to make interaction with the module's features, easier, faster, and scriptable.
In this tutorial we'll:
- Learn about the Drush core commands for common tasks like interacting with queues, performing database backups, and importing/exporting configuration
- Demonstrate how to find the Drush commands provided by contributed modules in your project
By the end of this tutorial you'll learn some popular commands for common tasks that'll speed up your daily work.
Every Drupal site consists of many Drupal projects like modules and themes. Drush comes with a group of commands that aid in managing projects from the command line. These commands can check which modules are present in a site's codebase, report their security status, enable modules, and display metadata for modules and themes. All of these commands start with the pm
prefix, and are part of the project manager group.
Common use cases for the project manager commands include: quickly enabling/disabling modules via the CLI rather than performing numerous clicks in the UI, and as part of CI/CD process that lists (or maybe even automates) security updates.
In this tutorial we'll:
- List the available
pm
commands - Enable a module with Drush
- Uninstall a module with Drush
- Use Drush to check for security updates for modules, themes and PHP packages
By the end of this tutorial you'll have an understanding of the project manager commands that come with Drush, how to use them, and how to speed up common workflows and maintenance tasks.
Administration and maintenance of Drupal websites consists of many tasks that can both be performed via the command line, and automated, with Drush. Using Drush's site and environment administration commands you can run database updates, check an environment's status, clear (rebuild) the cache, perform Cron-related operations, and manage users. These tasks are repetitive, often require many steps in the UI, and may be tedious in the long run. Learning to execute them with Drush can save you time and allows for more automation of common tasks.
In this tutorial we'll:
- Use Drush to check a site's status
- Learn how to perform database updates with Drush
- Clear the Drupal cache with Drush
- Use Drush to execute Cron tasks for a Drupal site
- Learn how to use Drush to login to a site as any user, and manage existing users
By the end of this tutorial you'll be able to perform many common Drupal environment and administration tasks from the command line with Drush. We're not going to cover all of the environment management commands in this tutorial, just some of the more popular ones. We encourage you to explore further on your own.
What Is Drush?
FreeDrush, aka The Drupal Shell, is a command line utility and UNIX scripting interface for Drupal. It allows access to common Drupal features and tasks via the command line. It can help speed up common tasks for Drupal site builders, developers, and DevOps teams. Among other things, it makes it easier to integrate Drupal into CI/CD workflows.
In this tutorial we'll:
- Learn what Drush is and what can be done with Drush
- Install Drush
- Find a list of Drush commands
- Learn how to execute commands
By the end of this tutorial, you'll understand how to install and use Drush with your Drupal projects, navigate the list of its commands and run them. This is intended as an overview. Other tutorials will provide more detail about common commands and use-cases.