Skip to content

Backgrounds

How-to Guides

Technical References

VIP Search /

Enable VIP Search features

⚠️ VIP Search is in limited beta

This documentation is subject to change. Features described here may not be available, may not be fully functional, or may change without notice, prior to general availability.

VIP Search does not index everything, and is currently focused mainly around posts. Other indexables/features available in the underlying ElasticPress 3.4.2 may be enabled, but they are not yet tested or guaranteed to work.

Only WordPress events trigger the underlying ElasticPress plugin hooks that cause the index to update. Directly modifying the database or editing data through means that aren’t handled by these hooks will not change the Elasticsearch (ES) index. For example, database imports will not change the ES index.

Editing most pieces of post data will result in incremental indexing. The exceptions are through the various allow lists in both ElasticPress and VIP Search. A very prominent example is the vip_search_post_meta_allow_list filter which controls which post meta are indexed. If it’s empty, no post meta is indexed.

Once you’ve set up the allow lists to match existing queries, you are ready to perform searches, but additional configuration is possible in order to send other arbitrary queries to Elasticsearch.

The following presumes that VIP Search has been enabled by adding the required constants to the code.

Posts

Posts are indexed by default.

Search is a feature that is enabled by default.

Queries with an s parameter will be automatically sent to Elasticsearch and searched against post_titlepost_content, and post_excerpt. This is highly beneficial because the default MySQL behavior, fulltext search with LIKE clauses, can result in poor database performance.

To prevent this behavior and force the query to go to MySQL, set the ep_integrate WP_Query parameter to false. (Keep in mind, this results in poor performance).

Terms

To index terms (taxonomies), you will need to explicitly enable this as a feature.

If you’ve created an allow list for taxonomies, then you’ll need to enable the feature and then initiate a re-index. You can do this via the VIP-CLI.

In the terminal, run the following commands to activate the feature, enable the terms mapping, and (re)index the terms.

Note

Because these are WP-CLI commands, you’ll need to pass them to the VIP-CLI, as demonstrated in the first example (where our app id is 103). We’ve omitted this prefix from the remaining commands for clarity.

$ vip @103 -- wp vip-search activate-feature terms
Warning: Feature is usable but there are warnings:
Warning: This feature requires a re-index. You may want to run the index command next.
Success: Feature activated

If you’re not using a multisite, the --network-wide option (to apply to all subsites) is not necessary. You can also specify just a single subsite of a multisite with --url.

Now that the feature is activated, we can enable the mapping and index just the terms:

wp vip-search put-mapping --network-wide --indexables="term"
wp vip-search index --network-wide --indexables="term"

Last updated: April 09, 2021