GithubHelp home page GithubHelp logo

isabella232 / elasticsearch-extensions Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alleyinteractive/elasticsearch-extensions

0.0 0.0 0.0 339 KB

Extensions to various Elasticsearch plugins to make it easier to implement common features like faceted search.

License: GNU General Public License v3.0

PHP 100.00%

elasticsearch-extensions's Introduction

Elasticsearch Extensions

read me standard badge

A WordPress plugin to make integrating sites with Elasticsearch easier:

  • Seamlessly and automatically integrates with different Elasticsearch plugins.
  • Simplifies common Elasticsearch operations like adding aggregations and filtering indexable post types, taxonomies, and postmeta in an implementation-agnostic way.

Table of Contents

Background

In most projects that need to integrate with an Elasticsearch provider, there is a lot of common code—configuring the post types to index and search, taxonomies, postmeta, and setting up front-end and back-end logic for handling aggregations (often referred to as faceted search). This plugin aims to provide a unified interface for the most common configuration options for Elasticsearch integrations on WordPress sites to reduce the amount of custom code or boilerplate that developers need to write on every project. Likewise, it aims to centralize updates so if something changes in an Elasticsearch plugin, the update likely only needs to be made to this plugin, which can in turn be updated on the sites that depend on it.

This plugin is a work in progress. It currently supports the following adapters:

With future support planned for the following adapters:

Test coverage is also a work in progress, but the goal is to have test coverage for all functionality for all adapters which also tests different versions of Elasticsearch (as is necessary and practical) using GitHub Actions.

Releases

All work on this plugin should be based off of main and pull requests should be made into main. Once sufficient work has been done to justify making a new release, it should be created using GitHub Releases, tagged, and described. Releases must follow semantic versioning. During the active development phase, releases should start with a 0 and we can move to a 1.0.0 once we have full test coverage and full support for all target adapters.

For a list of all releases, please see the releases page.

Install

In order to use this plugin, you must install it alongside a supported Elasticsearch plugin:

Use

Install and activate the plugin to have it interface with an existing installed Elasticsearch plugin. This plugin will automatically detect which supported Elasticsearch plugin is in use, and will register the appropriate hooks.

Customize the Elasticsearch integration using the elasticsearch_extensions_config action. Method calls can be chained for ease of configuration. For example:

add_action(
	'elasticsearch_extensions_config',
	 function( $es_config ) {
		$es_config
			->restrict_post_types( [ 'post', 'page' ] )
			->enable_empty_search()
			->enable_post_type_aggregation()
			->enable_taxonomy_aggregation( 'category' )
			->enable_taxonomy_aggregation( 'post_tag' );
	 }
);

For detailed information on all configuration options, action and filter hooks, and how to integrate aggregation controls into the search template, see the wiki.

From Source

In order to install this plugin to develop new features or fix bugs, you should first install a clean WordPress site, then clone this repository into the plugins folder:

$ cd wp-content/plugins
$ git clone [email protected]:alleyinteractive/elasticsearch-extensions.git

If you are using a fork to develop against, substitute the URL of your fork above.

Next, you need to run composer install in order to install dependencies, including the adapter plugins:

$ cd elasticsearch-extensions
$ composer install

This will install all current and planned adapter plugins. Regular WordPress plugins will be installed to plugins and VIP Enterprise Search will be installed as part of vip-go-mu-plugins in the mu-plugins folder.

In order to ensure you are developing against the latest version of these plugins, you may need to run composer update. Since there is a custom package configuration, if you haven't done so already, you may need to establish a GitHub access token to read package information via the API. Composer will prompt you if this is the case—follow the instructions it provides.

You will also need to ensure that you are running Elasticsearch in a location where the plugins can access it, and you will need to configure a connection to Elasticsearch for the plugin you are working on (e.g., VIP Enterprise Search).

Changelog

This project keeps a changelog.

Development Process

See instructions above on installing from source. Pull requests are welcome from the community and will be considered for inclusion.

Contributing

See our contributor guidelines for instructions on how to contribute to this open source project.

Project Structure

This project is built on an adapter pattern to allow for a common API that supports various Elasticsearch plugins. Adapters are extended from a base class and are available in lib/adapters.

Aggregations (faceted search) are a major feature of this plugin. Aggregations are defined, similarly to adapters, by extending a base class, and all aggregations are defined in lib/aggregations.

Tests are run via phpunit, verified by GitHub Actions when a pull request is created, and are located in the tests folder.

Interaction with Elasticsearch involves writing and modifying Elasticsearch DSL (Domain-Specific Language). There is a DSL class which should contain all DSL that the plugin needs to write. Specific DSL structures will differ based on which adapter is being used, so the adapters are each responsible for modifying the DSL that is written by the plugin in use in order to establish the same functionality for a developer or user irrespective of their chosen integration.

This plugin uses a factory pattern to handle creating a controller that loads an adapter based on which plugin is active.

Controller methods are chainable, following a common practice in Laravel, by returning the current object at the end of a function call. See the controller class to see how this works. This design choice makes it possible to call several configuration methods in a row without having to reference the object again (see the Use section above for an example of how this works in practice).

Third-Party Dependencies

In order to use this plugin, you need to have an Elasticsearch cluster available and a supported Elasticsearch plugin installed and configured to connect to it.

Related Efforts

This plugin is part of a collection of Elasticsearch open source plugins developed and maintained by Alley:

Maintainers

Alley logo

Contributors

Thanks to all of the contributors to this project.

License

This project is licensed under the GNU Public License (GPL) version 3 or later.

elasticsearch-extensions's People

Contributors

kevinfodness avatar jakewrfoster avatar renatonascalves avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.