If you are managing a WordPress multisite, these tips and suggestions for implementing Enterprise Search’s multisite features may be helpful.
Defining a multisite network for Enterprise Search
EP_IS_NETWORK constant is added to your
define( 'EP_IS_NETWORK', true );
Each subsite in a multisite has its own Elasticsearch index, and each may be set up differently if desired – either via a network-wide plugin or mu-plugin, or in theme code.
If you’re not implementing Enterprise Search on every multisite, or phasing it in one subsite at a time, you may need to disable sending search queries to Elasticsearch for subsites that are not ready.
However, we recommend setting up all subsites at the same time to avoid having some sites with non-functional searches.
After creating a new subsite
If you create a new subsite in a multisite, and search was already enabled for the multisite, you may need to create a search index for that site, or re-index it following a content import.
Each subsite has a separate index. Currently an index may not be created for a new subsite by default.
If the subsite has Enterprise Search enabled, then a test search can be used to check: run a search, open Search Dev Tools (available soon), and if there are no results, inspect the response JSON for an error such as “no index” or “index does not exist”.
You can also use the CLI to run a health check for the subsite, which should identify any setup issues. For example, after creating a new subsite (with a welcome post, welcome page, and comment), and adding a test post, there are inconsistencies. “welcome” is not found in a search and those items are not indexed, but the test post is indexed.
$ wp vip-search health validate-counts --url=mysubsite.example.com Validating post count ❌ inconsistencies found when counting entity: post, type: post, index_version: 1 - (DB: 2, ES: 1, Diff: -1) 🟧 skipping, because there are no documents in ES when counting entity: post, type: page, index_version: 1 Cannot find indexable 'user', probably the feature is not enabled
If no index exists for the subsite, or the health check reveals inconsistencies, then you may create a new index as follows:
$ wp vip-search index --setup --url=mysubsite.example.com Processed 3/3. Last Object ID: 1 Number of posts indexed: 3 Total time elapsed: 0.283 Success: Done! $ wp vip-search health validate-counts --url=mysubsite.example.com Validating post count ✅ no inconsistencies found when counting entity: post, type: post, index_version: 1 - (DB: 2, ES: 2, Diff: 0) ✅ no inconsistencies found when counting entity: post, type: page, index_version: 1 - (DB: 1, ES: 1, Diff: 0) Cannot find indexable 'user', probably the feature is not enabled
Command arguments for multisite
When initiating indexes or running health checks, the following CLI arguments are helpful, or necessary.
To run a command against all subsites in the multisite:
To run a command against just one specific subsite:
For example, when enabling the Terms indexable:
$ wp vip-search activate-feature terms $ wp vip-search put-mapping --indexables="term" --network-wide $ wp vip-search index --indexables="term" --network-wide