ElasticPress how to Include Meta to the mapping?

Solution 1

I haven’t tested the plugin, but based on this code from the link in your question:

apply_filters( 'ep_prepare_meta_whitelist_key', false, $key, $post )

You can do something like this to explicitly allow a protected/private meta key:

add_filter( 'ep_prepare_meta_whitelist_key', function( $allow, $meta_key ){
    $meta_keys = ['_one', '_two', '_etc']; // meta keys you want to allow
    return in_array( $meta_key, $meta_keys );
}, 10, 2 );

Solution 2

Alternatively, looking at this part, you could use the ep_prepare_meta_allowed_protected_keys filter to add your custom protected meta keys to the array of index-able private meta keys:

add_filter( 'ep_prepare_meta_allowed_protected_keys', function( $meta_keys ){
    return array_merge( $meta_keys, ['_one', '_two', '_etc'] );
} );

Summary

If I were you, I’d use the second solution. But it’s really up to you. 🙂

PS: The code would go in the theme functions file.