Skip to content

Commit

Permalink
Merge pull request #129 from pantheon-systems/processors-documentation
Browse files Browse the repository at this point in the history
CMS-426: Processors documentation
  • Loading branch information
stovak authored Dec 14, 2021
2 parents 8755a5d + 55825a9 commit 0bd8e93
Show file tree
Hide file tree
Showing 19 changed files with 14 additions and 325 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/tests/circle-scripts/drupal8/
.idea
.DS_Store
docs/Badge.confluence
217 changes: 4 additions & 213 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,12 @@
[![Search API Pantheon](https://github.com/pantheon-systems/search_api_pantheon/actions/workflows/ci.yml/badge.svg?branch=8.x)](https://github.com/pantheon-systems/search_api_pantheon/actions/workflows/ci.yml)

![Solr at pantheon diagram](docs/diagram.svg "Solr at pantheon")
<details>
<summary>Solr at Pantheon</summary>

```mermaid
graph TD
A[Solr Server] -->
B[Index] --> C{search_api_pantheon}
C -->|views| D[Search Form]
C -->|views| E[Search Page]
C -->|views| F[Robots]
H --> | Create Schema | G[search_api_pantheon_admin] --> |Post Schema| A
H[search_api_solr] --> C --> |indexed fields| B
I[Search_api] --> H
J[Drupal Entities] --> I
A --> |Status / Health| G
```
</details>


## Requirements

This module is for you if you meet the following requirements:

* Using Drupal 9.2+
* Using Drupal 8.8/9.2+

* Hosting the Drupal site on Pantheon's platform

Expand All @@ -46,203 +28,12 @@ and [Search API Solr](https://www.drupal.org/project/search_api_solr) on [Panthe
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 it's own [SOLR CORE](). Doing so eliminates the need to do extra work setting up Solr servers for each environment.
Pantheon Environment has it's 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](https://drupal.org) integration with the [Apache Solr project](https://solr.apache.org/guide/8_8/).
Pantheon's current version as of the update of this document is 8.8.1.

## 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](http://www.solarium-project.org/). 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](https://www.drupal.org/project/search_api). Search API is Drupal's module for indexing content entities.

- [Search API Solr](https://www.drupal.org/project/search_api_solr). Search API Solr makes search API work with Apache Solr. Composer will manaage which version

- [Guzzle](https://docs.guzzlephp.org/en/stable/). Guzzle version 6 is standard with Drupal Core `8.x | 9.x` (read 8.x OR 9.x).

## Install

To require this module in your composer file:

```
composer require pantheon-systems/search_api_pantheon ^8 --prefer-dist
```

Install the module and push an updated composer.lock file to your pantheon environment.

## Setup

### PLATFORM SUPPORT

See the [Drupal.org for complete documentation on Search API](https://www.drupal.org/node/1250878).
To configure the connection with Pantheon, do 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 (** SYNTAX NOT FINAL; Use pantheon internal YGG
instructions until yml support is final and available in prod **):

```yaml
php_version: 7.4
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.
### 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 useable, 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 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 added
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. Higher rating means Solr thinks the item is "more relevant" to your search term.

* **Export your changes**

* It is a best practice in Drupal 8 to export your changes to `yml` files.
Using Terminus while in SFTP mode, you can run `terminus --env=dev drush "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.

### Feedback and collaboration

Bug reports, feature requests, and feedback should be posted in [the drupal.org issue queue.](https://www.drupal.org/project/issues/search_api_pantheon?categories=All) For code changes, please submit pull requests against the [GitHub repository](https://github.com/pantheon-systems/search_api_pantheon) rather than posting patches to drupal.org.


# SOLR JARGON:

Much of the jargon used in the Solr paradigm is used elsewhere in both drupal and other technologies. Please familiarize yourself
with the concept usage in a Solr context:

* **Commit** - To make document changes permanent in the index. In the case of added documents, they would be searchable after a commit.

* **Core** - An instance of the solr server suitable for creating zero or more indices. Solr core is a way to represent a Lucene index
and a set of configurations that control the accessing and using of the index with Solr. It's the main object you will interact
with when working with Solr. You will create it, configure it, indexing data in it and preform queries on it. A Solr core
is a Lucene index but wrapped in Solr related configurations.

* **Collection** - Solr Cloud's version of a "CORE". Not currently used at Pantheon.

* **Document** - A group of fields and their values. Documents are the basic unit of data in a collection.
Documents are assigned to shards using standard hashing, or by specifically assigning a shard within
the document ID. Documents are versioned after each write operation. Not to be confused with a PDF
document which can be uploaded to Solr and searched via the SearchAPIAttachments module.

* **Facet** - The arrangement of search results into categories based on indexed terms.

* **Field** - The content to be indexed/searched along with metadata defining how the content should be processed by Solr.

* **Index** - A group of metadata entries gathered by solr into a searchable catalog.

* **Schema** - A series of plain text and XML files that describe the data Solr will be indexing. The schema tells the server
about the data that Solr will be indexing and tells solr how to return the results. Schema is generated automatically
by drupal and uploaded using the PANTHEON_ADMIN tab of this module.


# TROUBLESHOOTING

* `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 to get a good query to pass to this command to debug results.
### For more information, [please visit our wiki on Github](https://github.com/pantheon-systems/search_api_pantheon/wiki)
7 changes: 1 addition & 6 deletions RoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ public function testDowngradeToDrupal8(string $site_name) {
->args(
'require',
'--no-update',
'-W',
'drupal/core-recommended:^8',
'pantheon-systems/drupal-integrations:^8'
)
Expand All @@ -348,12 +349,6 @@ public function testRequireSolr(string $site_name, string $constraint = '^8') {
->args(
'require',
'pantheon-systems/search_api_pantheon ' . $constraint,
'drupal/search_api_autocomplete',
'drupal/search_api_sorts',
'drupal/facets',
'drupal/redis',
'drupal/devel',
'drupal/devel_generate'
)
->run();
return ResultData::EXITCODE_OK;
Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
"ext-curl": "*",
"ext-json": "*",
"ext-zip": "*",
"drupal/search_api_solr": "^4.2.1",
"guzzlehttp/guzzle": "^6",
"drupal/search_api_solr": "^4.2",
"guzzlehttp/guzzle": "^6.5.2",
"http-interop/http-factory-guzzle": "^1.0",
"php-http/guzzle6-adapter": "^2.0",
"psr/event-dispatcher": "^1.0"
Expand All @@ -54,6 +54,8 @@
"symfony/yaml": "^4"
},
"suggest":{
"drupal/search_api_autocomplete": "^1",
"drupal/search_api_spellcheck": "^3",
"drupal/search_api_page": "^1.0",
"drupal/facets": "^1.8",
"kint-php/kint": "@stable"
Expand Down
86 changes: 0 additions & 86 deletions docs/TROUBLESHOOTING-INDICES.md

This file was deleted.

13 changes: 0 additions & 13 deletions docs/diagram.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/diagram.svg

This file was deleted.

Binary file removed docs/images/screen_ajax_errors.png
Binary file not shown.
Binary file removed docs/images/screen_shot_1.png
Binary file not shown.
Binary file removed docs/images/screen_shot_2.png
Binary file not shown.
Binary file removed docs/images/screen_shot_add_fields.png
Binary file not shown.
Binary file removed docs/images/screen_shot_fields_1.png
Binary file not shown.
Binary file removed docs/images/screen_shot_fields_2.png
Binary file not shown.
Binary file removed docs/images/screen_shot_index.png
Binary file not shown.
Binary file removed docs/images/screen_shot_index_complete.png
Binary file not shown.
Binary file removed docs/images/screen_shot_index_content.png
Binary file not shown.
Binary file removed docs/images/solr_with_debug.png
Binary file not shown.
7 changes: 3 additions & 4 deletions search_api_pantheon.module
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ function search_api_pantheon_search_api_solr_config_files_alter(array &$files, s
unset($solrcore_properties[$key]);
}
}
// Replace it with the correct value
$solrcore_properties = implode(PHP_EOL, $solrcore_properties) . PHP_EOL;
$solrcore_properties .= 'solr.install.dir=/opt/solr' . PHP_EOL;
$files['solrcore.properties'] = $solrcore_properties;
// Remove the solrcore.properties file from the upload
// This file is causing undue issues with core restarts
unset($files['solrcore.properties']);
}
Loading

0 comments on commit 0bd8e93

Please sign in to comment.