Skip to content

Enable Enterprise Search

To fully enable Enterprise Search, the feature must be code-enabled then an Elasticsearch (ES) index for a site’s content is created using CLI commands. After those two steps are complete, standard search queries for the site will be offloaded to the newly created ES index.

  1. Code-enable the Enterprise Search feature by adding the VIP_ENABLE_VIP_SEARCH constant to vip-config.php and defining it as true.
  2. Add the VIP_ENABLE_VIP_SEARCH_QUERY_INTEGRATION constant to vip-config.php and define it as true to automatically send front-end search queries directly to Enterprise Search.
vip-config/vip-config.php
define( 'VIP_ENABLE_VIP_SEARCH', true ); // Enable Enterprise Search
define( 'VIP_ENABLE_VIP_SEARCH_QUERY_INTEGRATION', true ); // Integrate search queries with Enterprise Search
  1. If any other variants of Elasticsearch-backed functionality such as Jetpack Search or the es-wp-query adapter exist in the application codebase, disable or remove that code entirely. Enterprise Search uses forks of es-wp-query and ElasticPress that are loaded automatically. No other Elasticsearch-backed functionality can be supported while Enterprise Search is enabled.
  2. After code-enabling Enterprise Search, an Elasticsearch index must be generated with the wp vip-search index CLI command.
    • The first time an Enterprise Search index is created for a site, include the --setup command option. Later re-indexing should not include the --setup command, and instead should be performed with versioning to ensure proper mapping.
    • For WordPress multisite environments, indexes should be created per-network site.
  1. Verify with Search Dev Tools that frontend queries are successfully being sent to Elasticsearch by Enterprise Search.
  2. After fully Enterprise Search, signs of conflicts, PHP warnings, or issued notices can be monitored with debugging tools such as Query Monitor and Runtime Logs.

Test offloading of search queries

Verify that the Enterprise Search integration is working as intended for a site before fully enabling it for all search queries.

Testing the offloading of search queries to Enterprise Search can be performed after VIP_ENABLE_VIP_SEARCH has been defined as true in the codebase, but before the VIP_ENABLE_VIP_SEARCH_QUERY_INTEGRATION constant has been defined as true.

Sites that are already launched and serving traffic can avoid search downtime by completing one or both of these basic tests before fully enabling Enterprise Search.

URL parameter string

The parameter string vip-search-enabled=1 can be appended to a site’s URL to test the offloading of search queries to Enterprise Search.

To test offloading, search for a term on a site with Enterprise Search enabled. Append the parameter to the URL in the browser’s address bar and reload the browser. For example:

http://example.com/?s=<search-term>&vip-search-enabled=1

For the search term tomato, the URL would be structured similar to this example:

http://example.com/?s=tomato&vip-search-enabled=1

Refer to results in the Enterprise Dev Tools panel to verify that search is successfully being offloaded to Enterprise Search.

HTTP response header

Search requests that are successfully offloaded to Enterprise Search will return a X-ElasticPress-Query: true response header.

This is also true for requests made to a WP REST API search endpoint that are successfully offloaded to Enterprise Search. For example: https://example.com/wp-json/wp/v2/search?search=<search-term>.

Last updated: November 07, 2024

Relevant to

  • WordPress