WordPress plugin intelligence profile

Solr Search for WordPress

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

WP PlugIndex snapshot

Current directory snapshot

Tested up to WordPress 6.7
Current version2.6.0
WordPress coverageTested up to WordPress 6.7
Minimum stackWP 4.6 · PHP 7.1
Directory statusactive
Last directory update9 Dec 20241y ago
Active installations100Adoption metric — not a quality score
WordPress.org rating4.0 / 5 from 2 ratings
Official packageDirect from WordPress.org

Repository metrics are context, not quality scores. Active installations measure adoption and can strongly reflect a plugin’s age and historical popularity. Ratings, recent updates and “Tested up to” metadata also do not guarantee modern code, error-free operation, security, feature completeness or suitability for a particular site. Why active installs don’t tell the whole story →

WP PlugIndex currently records Solr Search for WordPress version 2.6.0 as active, updated 1y ago and tested up to WordPress 6.7.

Overview

About this plugin

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

Development

This plugin is under active development on GitHub:

com/pantheon-systems/solr-power

Please feel free to file issues there. Pull requests are also welcome! 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:

com/pantheon-systems/solr-power/wiki

You may notice there are two sets of tests running, on two different services:

  • PHPUnit test suite against a Solr instance.
  • The Behat test suite against a Pantheon site, to ensure the plugin’s compatibility with the Pantheon platform.

Both of these test suites can be run locally, with a varying amount of setup.

PHPUnit requires the WordPress PHPUnit test suite, and access to a database with name wordpress_test. sh wordpress_test root '' localhost. You’ll also need access to a running Solr instance, in order to run the unit tests against Solr.

Behat requires a Pantheon site with Solr enabled. Once you’ve created the site, you’ll need install Terminus, and set the TERMINUS_TOKEN, TERMINUS_SITE, and TERMINUS_ENV environment variables. sh to prepare the site for the test suite.

Note that dependencies are installed via Composer and the vendor directory is not committed to the repository. You will need to run composer install locally for the plugin to function. You can read more about Composer here

WP-CLI Support

This plugin has WP-CLI support.

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

] [--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. xml to Solr.

<h3>WP_Query Integration</h3>

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

)

Configuration Tips

Searching by author name

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

xml to Solr and reindex with the new schema.

xml:

TrieDateField" omitNorms="true" precisionStep="6" positionIncrementGap="0"/>

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

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. 16e-11,1,1))' ); return $dismax; } add_filter( 'solr_dismax_query', 'my_solr_dismax_query' );

is_solr_query Filter

The is_solr_query filter controls whether Solr should be used for a specific query.

Parameters:

  • $enabled (bool): Indicates whether Solr should be used for the query. Defaults to true if the query is a search or if solr_integrate is set in the query.
  • $query (WP_Query): The current WordPress query object.

Return:

-

bool: true to enable Solr for the query, false to disable it.

add_filter( ‘is_solr_query’, function( $enabled, $query ) {

if ( $query->is_category( ‘news’ ) ) {

return false;

}

return $enabled;

}, 10, 2 );

Custom schema file path

xml. This can be overridden with an absolute path using the the solr_power_customer_schema_file_path filter.

Parameters:

* $custom_schema_file_path (string): Default path to a custom schema file

Return:

xml file.

xml'; });

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.

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

WordPress.org metadata

Plugin tags

Topics listed for this plugin in the WordPress.org directory.

  • search
Compatibility & maintenance

Compatibility & maintenance

Tested up to WordPress 6.7

Not yet marked as tested with WordPress 7.1. WordPress.org currently lists Tested up to 6.7.

Current WordPress releaseWordPress 7.1
WordPress.org Tested up to6.7
Minimum requirementsWordPress 4.6 · PHP 7.1
Update activity9 Dec 20241y ago

“Tested up to” is directory metadata supplied by the plugin author. WP PlugIndex does not turn an older declaration into a claim that the plugin is incompatible.

Changes recorded by WP PlugIndex

Recent tracked changes

No tracked version or compatibility changes have been recorded by WP PlugIndex yet.

Tracking & source

WP PlugIndex tracks public WordPress.org directory metadata and records selected version, compatibility and availability changes as they are detected.

Plugin watchlist

Watch this plugin

Sign in to your WP PlugIndex account or create a free account. Free accounts can watch up to 5 plugins and see what changed.

Watch limit

Watchlist limit reached

You have reached your current active watch limit.