Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VIP Search adapter #2

Merged
merged 2 commits into from
May 15, 2020
Merged

Conversation

nickdaugherty
Copy link

Adds a VIP Search adapter for es-wp-query.

Depends on #1 (will rebase or merge)

Testing

In isolation this doesn't do much and depends on Automattic/vip-go-mu-plugins#1593

  1. Check out PR
  2. Check out Add Search::query_es() helper vip-go-mu-plugins#1593 for mu plugins
  3. In code, load the plugin and adapter:
wpcom_vip_load_plugin( 'es-wp-query' );
es_wp_query_load_adapter( 'vip-search' );
  1. Then run an offloaded query, like this:
add_filter( 'pre_get_posts', function( $query ) {
	if ( ! $query->is_main_query() ) { 
		return $query;
	}

	if ( $query->is_category() || $query->is_home() ) {
		$query->set( 'es', true );
	}
} );
  1. The above should register an ES query (in debug bar) and render the same posts that the DB query would

Copy link

@brandon-m-skinner brandon-m-skinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable enough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants