Skip to content

Instantly share code, notes, and snippets.

@tott tott/set-exact.php
Created Sep 11, 2019

Embed
What would you like to do?
Set ElasticPress Exact match
function set_to_exact( $formatted_args, $args ) {
if ( ! empty( $formatted_args['query']['bool']['should'] ) ) {
$formatted_args['query']['bool']['must'] = $formatted_args['query']['bool']['should'];
$formatted_args['query']['bool']['must'][0]['multi_match']['operator'] = 'AND';
unset( $formatted_args['query']['bool']['should'] );
unset( $formatted_args["query"]["bool"]["must"][0]["multi_match"]["type"] );
}
return $formatted_args;
}
add_filter( 'ep_formatted_args', 'set_to_exact', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.