• Stars
    star
    123
  • Rank 290,145 (Top 6 %)
  • Language
    PHP
  • License
    GNU General Publi...
  • Created over 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A WordPress plugin to connect to Pantheon's Apache Solr search infrastructure, or your own!

Solr Search for WordPress

Contributors: getpantheon, Outlandish Josh, 10up, collinsinternet, andrew.taylor, danielbachhuber, mattleff, mikengarrett, jazzsequence, jspellman, pwtyler
Tags: search
Requires at least: 4.6
Requires PHP: 7.1
Tested up to: 6.2
Stable tag: 2.5.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Improve your user experience with the Apache Solr search engine for your WordPress website.

Description

Actively Maintained CircleCI

Search is critical for your site, but the default search for WordPress leaves a lot to be desired. Improve your user experience with the Apache Solr search engine for your WordPress website.

  • Fast results, with better accuracy.
  • Enables faceting on fields such as tags, categories, author, and page type.
  • Indexing and faceting on custom fields.
  • Drop-in support for WP_Query with the solr_integrate parameter set to true.
  • Completely replaces default WordPress search, just install and configure.
  • Completely integrated into default WordPress theme and search widget.
  • Very developer-friendly: uses the modern Solarium library

Installation

The Solr Power plugin can be installed just like you'd install any other WordPress plugin.

Because Solr Power is intended to be a bridge between WordPress and the Apache Solr search engine, you'll need access to a functioning Solr 3.6 instance for the plugin to work as expected. This plugin does not support other versions of Solr. The plugin also requires PHP 7.1 or higher.

If you're using the Solr Power plugin on Pantheon, setting up Apache Solr is as easy as enabling the Apache Solr add-on in your Pantheon dashboard. Once you've done so:

  1. Configure which post types, taxonomies and custom fields to index by going to the Indexing tab of the Solr Power settings page.
  2. Index your existing content by going to the plugin options screen and selecting the applicable Actions:
      • Index Searchable Post Types
  3. Search on!
  4. See the examples/templates directories for more rich implementation guidelines.

If you're using the Solr Power plugin elsewhere, you'll need to install and configure Apache Solr. On a Linux environment, this involves four steps:

  1. Install the Java Runtime Environment.
  2. Run ./bin/install-solr.sh to install and run Apache Solr on port 8983.
  3. Configuring Solr Power to use this particular Solr instance by setting the PANTHEON_INDEX_HOST and PANTHEON_INDEX_PORT environment variables.
  4. Copying schema.xml to the Solr configuration directory (a path similar to solr/conf/schema.xml).

Alternatively, there are a couple of community-maintained Docker containers you may be able to use: kalabox/pantheon-solr, kshaner/solr.

In a local development environment, you can point Solr Power to a custom Solr instance by creating a MU plugin with:

<?php
/**
 * Define Solr host IP, port, scheme and path
 * Update these as necessary if your configuration differs
 */
putenv( 'PANTHEON_INDEX_HOST=192.168.50.4' );
putenv( 'PANTHEON_INDEX_PORT=8983' );
add_filter( 'solr_scheme', function(){ return 'http'; });
define( 'SOLR_PATH', '/solr/wordpress/' );

** Note for Lando users **

If you are using lando for development, the MU plugin is not needed. Lando auto configures everything for your local environment to connect to the docker index it maintains and if you overrite the ENV variables it will mess with that configuration.

Development

This plugin is under active development on GitHub:

https://github.com/pantheon-systems/solr-power

Please feel free to file issues there. Pull requests are also welcome! See CONTRIBUTING.md for information on contributing.

For further documentation, such as available filters and working with the SolrPower_Api class directly, please see the project wiki:

https://github.com/pantheon-systems/solr-power/wiki

WP-CLI Support

This plugin has WP-CLI support.

All Solr Power related commands are grouped into the wp solr command, see an example:

$ wp solr
usage: wp solr check-server-settings
   or: wp solr delete [<id>...] [--all]
   or: wp solr index [--batch=<batch>] [--batch_size=<size>] [--post_type=<post-type>]
   or: wp solr info [--field=<field>] [--format=<format>]
   or: wp solr optimize-index
   or: wp solr repost-schema
   or: wp solr stats [--field=<field>] [--format=<format>]

See 'wp help solr <command>' for more information on a specific command.

You can see more details about the commands using wp help solr:

**NAME**

  wp solr

**DESCRIPTION**

  Perform a variety of actions against your Solr instance.

**SYNOPSIS**

  wp solr <command>

**SUBCOMMANDS**

  check-server-settings      Check server settings.
  delete                     Remove one or more posts from the index.
  index                      Index all posts for a site.
  info                       Report information about Solr Power configuration.
  optimize-index             Optimize the Solr index.
  repost-schema              Repost schema.xml to Solr.
  stats                      Report stats about indexed content.

WP_Query Integration

Use Solr in a custom WP_Query instead of querying a database. Add 'solr_integrate' => true to the query arguments.

NOTE: Currently, only basic queries, tax_query, meta_query and date_query are supported. See examples/example.custom_WP_Query.php for an example.

A meta_query can use the following compare operators:

  • '='
  • '!='
  • '>'
  • '>='
  • '<'
  • '<='
  • 'LIKE'
  • 'NOT LIKE'
  • 'IN'
  • 'NOT IN'
  • 'BETWEEN'
  • 'NOT BETWEEN'
  • 'EXISTS'
  • 'NOT EXISTS'

('REGEXP', 'NOT REGEXP', and 'RLIKE' are not supported.)

Configuration Tips

Searching by author name

To support searching by author name (e.g. where "Pantheon" would return posts authored by the "Pantheon" user), add the following to your custom schema.xml:

<copyField source="post_author" dest="text"/>

Boosting relevancy score by publish date

The following guidance can be used to extend the Solr index and modify boosts beyond just this example.

To support math functions on dates, you must add a custom schema.xml to Solr and reindex with the new schema.

Add the following to schema.xml:

  <!-- Add to <types> -->
  <!-- See: https://lucene.apache.org/solr/6_2_0/solr-core/org/apache/solr/schema/TrieDateField.html -->
  <fieldType name="tdate" class="solr.TrieDateField" omitNorms="true" precisionStep="6" positionIncrementGap="0"/>

  <!-- Add to <fields> -->
  <field name="post_date_iso" type="tdate" indexed="true" stored="true" required="true" />

Add the following to your functions.php file.

  <?php
  /**
   * Hooks into the document build process to add post date field in proper format.
   */
  function my_solr_build_document( $doc, $post_info ) {
        $post_time = strtotime( $post_info->post_date );
        // Matches format required for TrieDateField
        $doc->setField( 'post_date_iso', gmdate( 'c\Z', $post_time ) );
        return $doc;
  }
  add_filter( 'solr_build_document', 'my_solr_build_document', 10, 2 );

  /**
   * Hooks into query processor, Dismax, to add publish date boost.
   * See: https://www.metaltoad.com/blog/date-boosting-solr-drupal-search-results
   */
  function my_solr_dismax_query( $dismax ) {
        $dismax->setQueryParser( 'edismax' );
        $dismax->setBoostQuery( 'recip(abs(ms(NOW/HOUR,post_date_iso),3.16e-11,1,1))' );
        return $dismax;
  }
  add_filter( 'solr_dismax_query', 'my_solr_dismax_query' );

Common issues

  • Failing to post the schema.xml will result in an error during indexing, "Missing post_date_iso field."
  • If you have the field and type in the schema, but don't add the solr_build_document filter, you will get a similar error.
  • If the post_date_iso field is missing from the index, Solr will ignore this boost and return regular results.
  • Trying to use a regular date field for the boost query will result in an error in the request instead of results.

Explicit Commit vs Autocommit

Once solr has sent the data to the solr server, solr must COMMIT the data to the index and adjust the index and relevancy ratings accordingly before that data can appear in search results.

By default, Solr Search for WordPress has auto-commit disabled. The index is committed when the uncommitted item is two minutes old, or the cron runs. By default, the cron runs on the Pantheon platform every hour.

When autocommit is enabled, Solr Search for WordPress commits data when it sends every post. When running on Pantheon, we recommend leaving autocommit disabled to aid overall site performance.

To enable autocommit, add the following to wp-config.php or an mu-plugin.

define( 'SOLRPOWER_DISABLE_AUTOCOMMIT', false );

To force-commit data outside of a normal cron run, from the command line, you can run the command below or simply force a cron-run.

wp solr commit

Security Policy

Reporting Security Bugs

Please report security bugs found in the Solr Power plugin's source code through the Patchstack Vulnerability Disclosure Program. The Patchstack team will assist you with verification, CVE assignment, and notify the developers of this plugin.

More Repositories

1

terminus

The Pantheon CLI — a standalone utility for performing operations on the Pantheon Platform
PHP
298
star
2

wp-redis

WordPress Object Cache using Redis.
PHP
204
star
3

wordpress-at-scale

Gathering best practices from the community to help developers and site owners find success in scaling WordPress.
197
star
4

documentation

Pantheon Docs
JavaScript
188
star
5

autotag

Git repository version tagging tool
Go
172
star
6

WordPress

WordPress upstream for the Pantheon website platform. Includes a platform integration plugins and a pre-configured wp-config.php.
PHP
157
star
7

quicksilver-examples

Example scripts for using Pantheon's Quicksilver Platform Hooks
PHP
128
star
8

wp-native-php-sessions

Implement native PHP sessions stored in the database for WordPress.
PHP
127
star
9

drops-7

Pantheon Upstream for Drupal 7 Sites
PHP
97
star
10

example-wordpress-composer

PHP
95
star
11

example-drops-8-composer

Install drops-8 with Composer on Pantheon.
Shell
94
star
12

wp_launch_check

WP-CLI Plugin to run checks against installation for Performance and Security
PHP
94
star
13

terminus-build-tools-plugin

Manage multidev environments for a Pantheon site using a GitHub PR workflow.
PHP
83
star
14

drops-8

Pantheon Upstream for Drupal 8 Sites. Deprecated; please see https://github.com/pantheon-upstreams/drupal-composer-managed
PHP
81
star
15

wp-saml-auth

Rock-solid SAML authentication for WordPress built on a modern foundation.
PHP
81
star
16

drush-config-workflow

Jumpstart your Drupal configuration merge magic with this repo's code and instructions.
Shell
68
star
17

example-terminus-auto-update-script

Shell
56
star
18

fusedav

Successor to git://git.0pointer.de/fusedav.git
C
45
star
19

docker-build-tools-ci

Dockerfile source for docker image pantheon-public/build-tools-ci on quay.io
Shell
33
star
20

github-gist-gutenberg-block

Include GitHub Gists in your Gutenberg posts without the hassle of shortcodes
Shell
33
star
21

pantheon-advanced-page-cache

Plugin to make the most of Pantheon's Global CDN with advanced page caching options.
PHP
32
star
22

pantheon-settings-examples

Pantheon optimized examples for hard-coded Drupal configuration in settings.php
PHP
28
star
23

terminus-secrets-plugin

A simple secrets management plugin for Terminus
PHP
22
star
24

kube-gce-cleanup

Clean up GCE network load-balancer resources left behind by kubernetes (GKE)
Shell
19
star
25

ariadne-extensions

Set of scripts and helper utilities to extend Ariadne GraphQL library
Python
17
star
26

terminus-site-clone-plugin

A Terminus plugin that adds the `site:clone` command to facilitate cloning sites on Pantheon
PHP
17
star
27

terminus-github-actions

A GitHub Action for setting up Pantheon's CLI tool, Terminus.
16
star
28

terminus-rsync-plugin

Terminus Plugin that provides a quick shortcut for rsync-ing files to and from a Pantheon site.
PHP
15
star
29

pantheon-wordpress-upstream-tests

Tests behavior of WordPress Core upstreams for Pantheon. Also within test suites of contrib plugins
Gherkin
15
star
30

iozone

iozone filesystem benchmark, based on v. 3_414
C
14
star
31

quicksilver-pushback

Push any commits made on the Pantheon dashboard back to the original GitHub repository.
PHP
14
star
32

pantheon-hud

Pantheon HUD plugin for WordPress providing a heads-up display into your Pantheon environment.
PHP
14
star
33

wordpress-network

This is a derived upstream from https://github.com/pantheon-systems/wordpress which contains the necessary configuration adjustments to make a WordPress Multisite successful on Pantheon.
PHP
14
star
34

decoupled-kit-js

Pantheon's monorepo for JavaScript SDKs, starter examples, and published npm packages.
JavaScript
14
star
35

terminus-mass-update

A Terminus plugin to apply upstream updates to multiple sites at once
PHP
13
star
36

cassandra-operator

operator for managing cassandra clusters
Go
12
star
37

terminus-composer-plugin

A Terminus plugin for running Composer commands on a Pantheon site
Shell
12
star
38

pantheon_domain_masking

Domain Masking helper module for D8
PHP
11
star
39

pantheon-wordpress-develop

A set of scripts to do nightly testing on Pantheon of the latest WordPress commits
PHP
11
star
40

site-audit-tool

Experimental project to extract Site Audit checks into a separate project
PHP
10
star
41

wordpress-bedrock-recommended

Shell
10
star
42

drupal-composer-managed

Pantheon platform's standard Drupal upstream, and recommended starter template for custom upstreams.
PHP
10
star
43

circleci-orb

Use CircleCI to push code to Pantheon Dev and Multidev Environments
10
star
44

drupal-integrations

Add this project to any Drupal distribution based on drupal/core-composer-scaffold to enable it for use on Pantheon.
PHP
10
star
45

pauditd

go based alternative to auditd
Go
9
star
46

terminus-site-debug

A Terminus plugin that can parse site logs and display NewRelic summary.
PHP
9
star
47

wordpress-composer

WordPress for Pantheon with a composer.json file.
PHP
9
star
48

pantheon-mu-plugin

Pantheon's WordPress mu-plugin for all WordPress-based upstreams.
PHP
8
star
49

docker_iptables

Utility to help manually manage iptables port mappings of Docker containers
Python
8
star
50

terminus-drupal-console-plugin

Run Drupal Console commands on Pantheon
Shell
7
star
51

terminus-installer

Installer for Pantheon Terminus
PHP
7
star
52

wp-decoupled-preview

Preview WordPress content on Front-end sites including Next.js
PHP
7
star
53

terminus-secrets-manager-plugin

Terminus Secrets Manager Plugin (Early Access)
PHP
7
star
54

drops-6

Pantheon Pressflow 6 for DROPs
PHP
7
star
55

search_api_pantheon

ApachSolr on Pantheon for Drupal 8/9 via Search API
PHP
7
star
56

example-drops-7-composer

Install drops-7 with Composer on Pantheon.
PHP
7
star
57

next-drupal-starter

This repository is a mirror. See https://github.com/pantheon-systems/decoupled-kit-js to join the discussion or submit an issue.
JavaScript
7
star
58

localdev-issues

Issue tracking for Pantheon localdev
6
star
59

drupal-recommended

DEPRECATED: Please use https://github.com/pantheon-upstreams/drupal-composer-managed
Shell
6
star
60

terminus_debugging_tools

A collection of terminus plugins to facilitate managing sites on Pantheon.
PHP
6
star
61

wordpress-composer-managed

WordPress boilerplate with Composer, easier configuration, and an improved folder structure
Shell
6
star
62

pmr

Process maps restarter
Python
6
star
63

drops-8-scaffolding

Scaffold files from drops-8: everything except /core, /composer.lock and /vendor
PHP
6
star
64

terminus-quicksilver-plugin

A Terminus plugin to help you get started quickly with Quicksilver
PHP
6
star
65

kube-gce-dns

Kube system service to register services in GCE DNS
Go
5
star
66

gatsby-starter-default

Development repository for Pantheon's Gatsby starter
CSS
5
star
67

countdown-timer-gutenberg-block

JavaScript
5
star
68

pantheon-image-enrichment

Proof of Concept - using Google Vision API to add value to WordPress
PHP
5
star
69

go-certauth

Go handlers and middleware to do client cert authentication.
Go
5
star
70

go-healthz

Package that implements a healthcheck server
Go
4
star
71

downstream-updater

Scripts useful for building a Continuous Integration system to update and test new releases from an upstream project.
Shell
4
star
72

pantheon-content-cloud-sdk

TypeScript
4
star
73

terminus-composer-logs-plugin

Terminus plugin to show composer logs.
PHP
4
star
74

redis

PHP
4
star
75

tbt-ci-templates

CI Integrations for Terminus Build Tools template repos
Shell
4
star
76

pantheon_log_retriever

PHP, Shell, Python and Perl script for app and db server log retrieval
PHP
4
star
77

smart_content_cdn

An experimental Drupal module to leverage Edge Integrations
PHP
4
star
78

update-tool

The Update Tool is responsible for detecting available software updates and creating pull requested as needed.
PHP
4
star
79

baryon

Layered Chef Universe Server
Go
4
star
80

nginx

Fork from git://pkgs.fedoraproject.org/nginx.git with support for systemd socket activation, full WebDAV, and syslog logging
Shell
4
star
81

selenium-zoetrope

PHP
4
star
82

systemd

Pantheon's very shallow fork of the official Fedora package
Shell
4
star
83

pantheon-edge-integrations

PHP
3
star
84

phpcompatibility-action

Shell
3
star
85

php-remote-error-monitor

PHP Module replacing APM in PHP 8
C
3
star
86

terminus-aliases-plugin

A plugin for Terminus which creates a complete aliases file.
PHP
3
star
87

dnscheck

DEPRECATED - no longer maintained. A PHP app to check that your DNS is correctly configured for Pantheon routing.
Less
3
star
88

fastly-io

WordPress plugin to let Fastly IO handle all the media library cropping and resizing
PHP
3
star
89

alpine-node

Tiny Node.js container built on alpine linux
Dockerfile
3
star
90

composer-lock-docker

Provides a "composer lock" service as a Python Flask app in a docker container.
Python
3
star
91

pantheon_advanced_page_cache

Drupal cache metadata + Pantheon's Global CDN
PHP
3
star
92

terminus-plugin-example

A simple plugin for Terminus to demonstrate how to add new commands
PHP
3
star
93

terminus-conversion-tools-plugin

Conversion Tools is a Terminus plugin that contains commands to convert a standard Drupal site into a composer managed one.
PHP
3
star
94

terminus-autopilot-plugin

PHP
2
star
95

etl-framework

Python
2
star
96

apm

Legacy APM version for PHP log submission.
C
2
star
97

vue-agcdn-mgmt

Vue app for AGCDN management
Vue
2
star
98

drupal-9-with-circleci-orb

PHP
2
star
99

markdown-toc-docker

markdown-toc CLI in a small docker container
Dockerfile
2
star
100

advanced-ci-templates

DEPRECATED - Advanced Templates and CI Integrations for Terminus Build Tools projects
Shell
2
star