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 both as true.
  • VIP_ENABLE_VIP_SEARCH : Enables Enterprise Search
  • VIP_ENABLE_VIP_SEARCH_QUERY_INTEGRATION: Integrates search queries with Enterprise Search
vip-config/vip-config.php
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.

Test offloading of search queries

Testing and verifying the offloading of search queries to Enterprise Search is useful when in the process of migrating to Enterprise Search and at any time verifying that integration is working as intended.

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 before the VIP_ENABLE_VIP_SEARCH_QUERY_INTEGRATION constant has been defined as true in the codebase. This is especially useful for a site that is in the process of transitioning to Enterprise Search and is already receiving public traffic.

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

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: January 18, 2024

Relevant to

  • WordPress