Search filter triggered & sort by custom post type

That doesn’t appear to be a WordPress post Loop so you will need to pass the post ID or the post object to get_post_type. I don’t know much about Relevansi but in your code above, that looks like $hit might be that object.

However, I don’t think that is what you want. I may be reading you wrong but it sounds like you want “if on a category archive page” and not “if this post is a”. In that case the function you need are these– the “Conditional Tags”.

So this…

// If post type = dogs, cats, horses
if (in_array( get_post_type(), array('dogs','cats','horses'))){
  // ...
}

Becomes (using is_post_type_archive)…

// If post type = dogs, cats, horses
if (is_post_type_archive('dogs')
    || is_post_type_archive('cats')
    || is_post_type_archive('horses')
){
   // ...
}