humanmade/elasticpress-stopwords

WordPress plugin to integrate WordPress stopwords with ElasticPress mapping.

Installs: 1 549

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 21

Forks: 1

Open Issues: 1

Type:wordpress-plugin

dev-main 2021-01-22 21:26 UTC

This package is auto-updated.

Last update: 2022-09-23 01:01:26 UTC


README

ElasticPress Stopwords
Integrates WordPress stopwords and filters with ElasticPress mapping.
68747470733a2f2f686d6e2e6d642f636f6e74656e742f7468656d65732f686d6e6d642f6173736574732f696d616765732f686d2d6c6f676f2e737667
A Human Made project

ElasticPress stopwords allows developers to customize stopwords functionality of Elastic through linking ElasticPress mapping with WordPress default stopwords list and using related filter wp_search_stopwords.

Requirements

  • PHP >= 7.1
  • WordPress >= 5.3
  • ElasticPress >= 3.4.3 (not tested with older versions)

Getting Set Up

Install Using Composer

composer require humanmade/elasticpress-stopwords

Load the plugin

require_once __DIR__ . '/vendor/humanmmade/elastic-stopwords/plugin.php';

Once you've installed the plugin, use the following code to manage stopwords:

add_filter( 'wp_search_stopwords', function( array $stopwords ) : array {
    $words_to_remove = [ 'foo' ];
    $words_to_add    = [ 'bar' ];
    return array_merge( array_diff( $stopwords, $words_to_remove ), $words_to_add );
} );

Credits

Created by Human Made with ❤️

Written and maintained by Shady Sharaf.

Interested in joining in on the fun? Join us, and become human!