WP_Query: how to search tags in addition to a custom post type?

Seems that WP_Query does not have the ability to query tags or categories. I ended up using the get_tags WordPress function and passed in the search term then merged the result with the WP_Query of the “places” endpoint.

function placesSearch() {
  register_rest_route('placesdb/v1', 'search', array(
    'methods' => WP_REST_SERVER::READABLE,
    'callback' => 'placesSearchResults'
  ));
}
function placesSearchResults($data) {
  $places = new WP_Query(array(
    'post_type' => array('place'),
    's' => sanitize_text_field($data['term'])
  ));
  wp_reset_postdata();

  $placesResults = array();

  while($places->have_posts()) {
    $places->the_post();
    array_push($placesResults, array(
      'title' => get_the_title(),
      'permalink' => get_the_permalink()
    ));
  }

  $tags = get_tags(array(
    'search' => sanitize_text_field($data['term'])
  ));

  $tagsResults = array();

  foreach ($tags as &$tag) {
    array_push($tagsResults, array(
      'title' => $tag->name,
      'permalink' => get_tag_link($tag->term_id)
    ));
  }

  return array_merge($placesResults, $tagsResults);
}
add_action('rest_api_init', 'placesSearch');