pantheon-systems / search_api_pantheon
Connection module for Pantheon Search (solr 8)
Installs: 452 716
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 8
Forks: 24
Open Issues: 14
Type:drupal-module
Requires
- php: >=7.4
- ext-curl: *
- ext-json: *
- ext-zip: *
- drupal/search_api_solr: ^4.3
- guzzlehttp/guzzle: ^6.5.7|^7.5
- http-interop/http-factory-guzzle: ^1.0
- kint-php/kint: ^4.1|^5
- psr/event-dispatcher: ^1.0
- symfony/finder: ^4.4|^5|^6
- symfony/yaml: ^4.4|^5|^6
Requires (Dev)
- consolidation/robo: ^3.0
- czproject/git-php: ^4.0
- drupal/coder: @stable
- phpunit/phpunit: @stable
- psy/psysh: @stable
- squizlabs/php_codesniffer: @stable
Suggests
- drupal/facets: ^1.8
- drupal/search_api_autocomplete: ^1
- drupal/search_api_page: ^1.0
- drupal/search_api_spellcheck: ^3
- kint-php/kint: @stable
- 8.x-dev
- 8.2.x-dev
- 8.2.2
- 8.2.1
- 8.2.0
- 8.1.x-dev
- 8.1.10
- 8.1.9
- 8.1.8
- 8.1.7
- 8.1.6
- 8.1.5
- 8.1.4
- 8.1.3
- 8.1.2
- 8.1.1
- 8.1.0
- 8.0.x-dev
- 8.0.3
- 8.0.2
- 8.0.1
- 8.0.0
- 8.0.0-Beta10
- 8.0.0-beta9
- 8.0.0-beta8
- 8.0.0-beta7
- 8.0.0-beta6
- 8.0.0-beta5
- 8.0.0-beta3
- 8.0.0-beta2
- 8.0.0-beta1
- 8.0.0-alpha5
- 8.0.0-alpha4
- 8.0.0-alpha3
- 8.0.0-alpha2
- 8.0.0-alpha1
- 3.x-dev
- 3.0.2
- 3.0.1
- 3.0.0
- dev-d11-compatible
- dev-rename-catalog-info-20240923
- dev-add-catalog-workflow-20241010
- dev-jeli-93-ugh
- dev-jeli-93-ii
- dev-jeli-93
- dev-jeli-93-alt
- dev-docs-updates
- dev-sync-8x-squashed
- dev-reload-after-post
- dev-reload-after-post-partial
- dev-add-catalog-info-20240910
- dev-issue-3467907-error-when-trying
- dev-181-ddev
- dev-BUGS-7551-Hook-Deprecation
- dev-HOTFIX-actions-permissions
- dev-BUGS-6560-Tag-Branches
- dev-1.x-(DEPRECATED)
- dev-BUGS-6240
- dev-guzzle-security
- dev-bugs-5488
- dev-d10-compatibility
- dev-cms-1125-d10-compatibility
- dev-add-back-kint
- dev-zookeeper-poc
- dev-cms-447
- dev-processors-documentation
- dev-BUGS-4278
- dev-remove-version-from-composer
- dev-cms-401-document-select
- dev-cms-400-check-pantheon-yml
- dev-test-ci-image
- dev-fix-d9-commit
- dev-troubleshooting
- dev-container-fixes
- dev-cms-246-fix-get-file
- dev-CMS-329
- dev-CMS-244
- dev-stovak
- dev-8.x-starting-e2e-tests
- dev-feature/ci-code-validation
- dev-feature/display-healt-and-stat
- dev-github-actions
- dev-drupal9ci
- dev-commenting-out-PHP-sniffing-in-CI
- dev-add-license-2
- dev-add-license-1
- dev-moreLikeThis
This package is auto-updated.
Last update: 2024-12-10 19:20:15 UTC
README
Important Notice - Schema Reversion Prevention
Starting with version 8.2, this module includes critical fixes to prevent Solr schema reversions that could cause:
- Search functionality outages
- Loss of indexed content
- Unexpected schema reversions
- Site downtime
Users experiencing these issues should upgrade immediately to version 8.1.x-dev.
Requirements
This module is for you if you meet the following requirements:
-
Using Drupal 9.4/10
-
Hosting the Drupal site on Pantheon's platform
-
Your site uses
composer
to install modules and upgrade Drupal core using one of the following integrations:- Pantheon's integrated composer (
build step: true
in your pantheon.yml) - A Continuous Integration service like Circle CI or Travis
- Pantheon's integrated composer (
-
Have Dashboard access to the platform (necessary to deploy code changes)
Intent
This module is meant to simplify the usage of Search API and Search API Solr on Pantheon's Platform.
Search API Solr provides the ability to connect to any Solr server by providing numerous configuration options. This module automatically sets the Solr connection options by extending the plugin from Search API Solr. The module also changes its connection information based on different Pantheon environments and each Pantheon Environment has its own SOLR CORE. Doing so eliminates the need to do extra work setting up Solr servers for each environment.
What it provides
This module provides Drupal 9 and 10 integration with the Apache Solr project. Pantheon's current version as of the update of this document is 8.11.4.
Composer
Composer is the way you should be managing your drupal module requirements. This module will install its dependencies when you use composer to install.
Dependencies (installed by Composer):
- Solarium. Solarium is a Solr client library for PHP and is not Drupal-specific. First, register Drupal.org as a provider of Composer packages. This command should be run locally from the root directory of your Drupal 8 git repository.
- Search API. Search API is Drupal's module for indexing content entities.
- Search API Solr. Search API Solr makes search API work with Apache Solr. Composer will manage which version.
- Guzzle. Guzzle version 6 is standard with Drupal Core
9.x | 10.x
(read 9.x OR 10.x).
Install
Stable Release
To install this module via composer, run the following command in your Drupal root:
composer require 'drupal/search_api_pantheon:^8.1'
Development Version
Note that the above will install the latest stable release of this module. To install the latest development version, use:
composer require 'drupal/search_api_pantheon:8.1.x-dev@dev'
Setup
Platform Support
See Drupal.org for complete documentation on Search API. To configure the connection with Pantheon, perform the following steps on your Dev environment (or a Multidev):
Enable Solr on your Pantheon site
- Under "Settings" in your Pantheon site dashboard, enable Solr as an add on. This feature is available for sandbox sites as well as paid plans at the Professional level and above.
Enable Solr 8 in your pantheon.yml file
-
Add the bolded portion to your
pantheon.yml
file:php_version: 8.1 database: version: 10.4 drush_version: 10 search: version: 8
As you promote the code, the
pantheon.yml
file will follow the code through environments enabling the Solr server. However you will need to create an index for each environment and ensure the content is indexed after creation. Indices are specific to the Solr core with/for which they were created. Indices cannot be exported or moved once created.
Core Reloading
Automatic Core Reload
Starting with version 8.1.x, Search API Pantheon automatically reloads the Solr core after schema updates to prevent schema reversions and maintain index integrity.
Schema Updates
Schema updates can be performed through:
- Admin UI: Navigate to
/admin/config/search/search-api/server/pantheon_solr8/pantheon-admin/schema
- Drush: Run
drush search-api-pantheon:postSchema
Manual Core Reload
If needed, manually reload the core using:
drush search-api-pantheon:reload
Usage
Enable the modules
- Go to
admin/modules
and enable "Search API Pantheon." - Doing so will also enable Search API and Search API Solr if they are not already enabled.
OPTIONAL: Disable Drupal Core's search module
- If you are using Search API, then you probably will not be using Drupal Core's Search module.
- Uninstall it to save some confusion in the further configuration steps:
admin/modules/uninstall
.
The module should install a SEARCH API server for you
- Navigate in the Drupal interface to
CONFIG
=>SEARCH & METADATA
=>SEARCH API
- Validate that the
PANTHEON SEARCH
server exists and is "enabled".
Solr versions and schemas
- The version of Solr on Pantheon is Apache Solr 8.8. When you first create your index or alter it significantly, you will need to update the SCHEMA on the server. Do that either with a drush command or in the administration for the Solr Server.
- Navigate to
CONFIGURATION
=>SEARCH AND METADATA
=>SEARCH API
=>PANTHEON SEARCH
=>PANTHEON SEARCH ADMIN
- Choose the button labeled "Post Solr Schema".
- The module will post a schema specific to your site.
Use the server with an index
The following steps are not Pantheon-specific. This module only alters the the configuration of Search API servers. To use a server, you next need to create an index.
- Go to
admin/config/search/search-api/add-index
. - Name your index and choose a data source. If this is your first time using Search API, start by selecting "Content" as a data source. That option will index the articles, basic pages, and other node types you have configured.
- Select "Pantheon" as the server.
- Save the index.
- For this index to be usable, you will also need to configure fields to be searched.
Select the "fields" tab and
CHOOSE FIELDS TO BE INCLUDED IN THE INDEX
. You may want to index many fields. "Title" is a good field to start with. - After adding fields to the configuration, make sure the index is full by clicking "Index now" or by running cron.
Search the Index
- Create a new view returning
INDEX PANTHEON SOLR8
of type 'ALL'. Don't worry right now how it's sorted, we're going to change that to 'relevance' once we have some data being returned during the search. - In the view,
CHOOSE FIELDS TO BE INCLUDED IN THE RESULTS
from the fields you added to your index when you created it. In addition to the fields you added to the index, choose 'relevance' to add to the results. - Expose any keywords to the user to change and the view will put a KEYWORDS
- Once your search is returning results, you can now sort by the "relevance" field and Solr will give the documents a relevance rating. A higher rating means Solr thinks the item is "more relevant" to your search term.
Export your changes
- It is a best practice in Drupal z to export your changes to
yml
files. Using Terminus while in SFTP mode, you can runterminus drush [PANTHEON_SITE].[PANTHEON_ENV] -- "config:export -y"
to export the configuration changes you have made. Once committed, these changes can be deployed out to Test and Live environments.
Optional Installs
Any of the optional search_api
modules should work without issue with Pantheon Solr, including but not limited to:
- Search API Attachments
- Search API Facets
- Search API Autocomplete
- Search API Spellcheck
- Search API Ajax
Pantheon Environments
Each Pantheon environment (Dev, Test, Live, and Multidevs) has its own Solr server. Indexing and searching in one environment does not impact any other environment.
Solr Jargon
Troubleshooting
Schema Reversion Issues
If you experience schema reversion issues:
- Verify you're using version 8.1.x-dev or later
- Check that core reloading is functioning after schema updates
- Monitor the Drupal logs for schema update messages
- Use
drush search-api-pantheon:diagnose
to verify configuration
Common Issues
Diagnostic Commands
-
drush search-api-pantheon:diagnose
(sapd
) The DIAGNOSE command will check the various pieces of the Search API install and throw errors on the pieces that are not working. This command will develop further as the module nears general availability. -
drush search-api-pantheon:select
(saps
) This command will run the given query against Solr server. It's recommended to use?debug=true
in any Solr page (having the right permissions) to get a good query to pass to this command to debug results. -
drush search-api-pantheon:force-cleanup
(sapfc
) This command will delete all of the contents for the given Solr server (no matter if hash or index_id have changed). -
drush search-api-pantheon:postSchema [solr-server] [path-to-schema]
(sapps
) This command will upload schema files to the solr server. It can be used to reset a solr schema to the default Pantheon configuration, upgrade a schema, or to use a custom config set.
The current default schema on Pantheon when a new Solr container is provisioned is the 4.2.1 version of the solr8 jump-start config set provided by the Search API Solr module. To upgrade the default Pantheon solr 8 server to a version 4.3.0+ compatible config set, run the following command after you've upgraded the Search API Solr module to your desired version.
drush search-api-pantheon:postSchema pantheon_solr8 /code/web/modules/contrib/search_api_solr/jump-start/solr8/config-set/
Once you have enabled the Search API Pantheon module, when you reload the schema the Pantheon module will use the config-set for the version of the Search API Solr module installed in your codebase. See the Search API Solr 4.3.0 release notes for more information about upgrading to a 4.3.0+ compatible schema.
drush search-api-pantheon:test-index-and-query
(sap-tiq
) This command will connect to the solr8 server to index a single item and immediately query it.
Feedback and Collaboration
Bug reports, feature requests, and feedback should be posted in the drupal.org issue queue. For code changes, please submit pull requests against the GitHub repository.