Custom pagination search in post type with meta key

The the_posts_pagination probably relies on the main query. You will need to “hack” the query global var or simple replace the main query (if you’re not using it afterwards).

So replacing the main query:

//$allsearch= &new WP_Query( $posts );
query_posts($posts);

Or replacing the main query vary

$allsearch= &new WP_Query( $posts );
$backup = $GLOBALS['wp_query'];
$GLOBALS['wp_query'] = $allsearch;

the_posts_pagination();

$GLOBALS['wp_query'] = $backup;

Also, I’ve noted you used a variable named $posts. I’ve already faced some issues using global variable names with queries, so I do not recommend using a variable named $posts