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