Skip to content

Enable Enterprise Search in code

Enable Enterprise Search in order to have Elasticsearch (ES) index a site’s content and offload standard search queries.

  1. Add two constants to vip-config.php and define them as true.
  • VIP_ENABLE_VIP_SEARCH : Enables Enterprise Search
  • VIP_ENABLE_VIP_SEARCH_QUERY_INTEGRATION: Integrates search queries with Enterprise Search
define( 'VIP_ENABLE_VIP_SEARCH', true ); // Enables Enterprise Search
define( 'VIP_ENABLE_VIP_SEARCH_QUERY_INTEGRATION', true ); // Integrates search queries with Enterprise Search
  1. After code-enabling Enterprise Search, indexing is required.

Transitioning to Enterprise Search from Jetpack

Sites that are currently using Jetpack Search, and already launched and serving traffic, can avoid search downtime by:

  1. Enabling Enterprise Search by adding the VIP_ENABLE_VIP_SEARCH constant to vip-config.php and defining it as true. This will initiate the indexing of new, incremental changes without affecting Jetpack Search.
  2. Run an index for the existing site content.
  3. If needed, create allow lists to define what is indexed.
  4. Verify that the newly created index is reporting good health and test search queries.
  5. It is recommended to look for any usages of the filters jetpack_search_es_wp_query_args or jetpack_search_es_query_args in the codebase and modify them to use the equivalent ep_formatted_args_query or ep_formatted_args . Since the ES queries are not 1:1 for Jetpack and Enterprise Search, this will require testing the alterations.

Once it is determined that the site is ready to transition off of its current Elasticsearch service into Enterprise Search:

  1. Add the VIP_ENABLE_VIP_SEARCH_QUERY_INTEGRATION constant to vip-config.php and define it as true. This will automatically send front-end search queries directly to Enterprise Search and disable the Jetpack Search module.
  2. Verify that Enterprise Search is sending its queries to Elasticsearch by using Search Dev Tools.
  3. Disable and remove all other Elasticsearch-backed functionality such as Jetpack Search, the es-wp-query adapter, or other variants of Elasticsearch. No other Elasticsearch-backed functionality can be supported while Enterprise Search is enabled. Enterprise Search uses forks of es-wp-query and ElasticPress that are loaded automatically.
  4. If there was any code that made search endpoint calls to the public API (e.g.<site ID>/search), modify it to use the WordPress core one instead at<search term> .
  5. Review New Relic’s error logs for conflicts, PHP warnings or issued notices.

Jetpack migration support path

define( 'VIP_SEARCH_MIGRATION_SOURCE', 'jetpack' );

For sites that are using the jetpack_sync_post_meta_whitelist filter, the constant VIP_SEARCH_MIGRATION_SOURCE can be added to vip-config.php and defined as jetpack. Jetpack’s default post meta allow list, and the values that are being filtered will be used as a base in the post meta allow list.

Testing search queries

The query string &vip-search-enabled=1 can be appended to a site’s URL to test if queries are sent to Enterprise Search without defining the VIP_ENABLE_VIP_SEARCH_QUERY_INTEGRATION constant.

For example, to test Enterprise Search with the search term “test” on a site with the domain “”, the full URL to test in a browser:

Last updated: August 03, 2023

Relevant to

  • WordPress