Developer How-Tos

Advanced tips and tricks for extending ElasticPress with code

How to Programmatically Index Posts using ElasticPress

ElasticPress uses WordPress actions and filters to keep your content automatically synced: every time a post, page, or custom post type is added, edited, or deleted via WordPress functions, ElasticPress will sync that content in…

How to disable fuzziness

As explained in this article: Depending on how your users search, you may or may not want fuzzy matching enabled. While fuzzy matching seems like a great feature (and it can be), it can create…

How to integrate ElasticPress with AJAX requests

As AJAX requests in WordPress are executed in an admin context (it is located at wp-admin/admin-ajax.php after all), some custom code is required to fully integrate your queries with ElasticPress. First, adding ‘ep_integrate’ => true…

Overriding Autosuggests Limits

Autosuggest provides real-time search suggestions to users as they type. One of the benefits of this feature is that it allows the number of displayed suggestions per search query to be controlled. In this article,…

I would like to run custom WP_Query calls through ElasticPress. How can I do this?

By default, ElasticPress integrates with all search queries on your WordPress site that use the WP_Query ‘s‘ parameter. Depending on additional Features you activate, such as Facets, ElasticPress may also integrate with certain other queries,…

I need to customize my search results and / or the way my data is indexed. Where can I find documentation?

ElasticPress offers several Features to help you control your search results in your WordPress Dashboard, such as the Weighting Engine and Custom Search Results tool. However, you may find that you want to customize results…

How can I search across multiple sites in a multi-site?

For multi-site (aka Network Mode) installations of WordPress, ElasticPress offers the custom site__in WP_Query parameter. This parameter lets you specify a number of different options to search across one or multiple sites in the network….

How to exclude metadata from indexing

NOTE: This snippets are meant for versions older than ElasticPress 5.0 or if you are using the ep_meta_mode filter with auto as value. Remove all metadata and choose individual fields to be indexed Exclude certain…

Search all meta keys matching a pattern

By default, ElasticPress indexes all public metadata. However, in order to search through a number of fields in your index (perhaps all associated with a particular plugin), you may find it easier to add these…