If you are still using the search from core, you should switch to for example search_api.
That beeing sayed, if you wish to avoid installing another contrib module and are willing to implement the functionality as a part of custom module. You could set excluded node types (programmatically) and then use hook_query_alter to filter out those types from each search.