Jetpack Search options
Replacing WP_Query
We also support other advanced use cases with Elasticsearch outside of search, like offloading expensive queries.
You can use the es-wp-query plugin from Alley Interactive to offload any WP_Query lookup to Elasticsearch for the increased performance of a variety of workloads. Use of the plugin is as simple as adding ’es’ => true
to your query params when building the WP_Query object.
While Elasticsearch does generally speed up most queries, there may be cases where Elasticsearch is slower. This depends on various factors like the speed of the original MySQL query (using a primary key like ID
or an index), the complexity of the Elasticsearch query, cost of the network round-trip, and so on. Query times and complexity should be carefully measured before deciding to offload.
Querying multiple sites
Searching across sites is not currently supported via Jetpack Search.
Non-public content
To search for non-public content, you can make authenticated requests to the API. This can be done by filtering the Elasticsearch arguments. We recommend doing so via client-mu-plugins
:
add_filter( 'jetpack_search_es_query_args', function( $es_query_args ) {
$es_query_args['authenticated_request'] = true;
return $es_query_args;
} );
This will make an authenticated (as your JP site) request to the Elasticsearch API, which provides access to non-public content.
Admin search
We’re exploring ways to add Jetpack Search capabilities to the admin to allow for faster and more relevant searches for editorial teams. Stay tuned for more.
Mapping
More information about how content from your WordPress site is mapped to the Elasticsearch index, can be found here.
The code that handles the mapping/translation can be found here.