The terms "patent search" and "prior art search" are often used interchangeably.
A patent search or prior art search is sometimes conducted before filing a patent application - provisional application, non-provisional (utility) application, or design application. A patent search or prior art search is not required before filing a patent application. The search is just a useful tool.
The purpose of the search is to uncover prior inventions that are identical and/or similar to the invention that may be the subject of a patent application to be filed. Prior means some type of public disclosure of the invention before your patent application is filed.
The prior disclosure can be in the form of patent applications that have been published, issued patents, articles, and advertisements.
If a prior disclosure is identical to your invention, any patent that issues from your patent application would be invalid.
If one or more prior disclosures makes your invention obvious, then again, any patent that issues from your patent application would be invalid.
What is considered obvious is not an easy question to answer. The question is answered by asking whether one skilled in the art of your invention would see your invention as being obvious in view of the prior disclosures. This question is usually best answered by a patent attorney, though even an attorney cannot give an answer with 100% certainty.
Based on the search results, one can then make a decision on whether it is worth the time and money to file a patent application.
Even if a prior art search or patent search is conducted, there is no guarantee that you will find all relevant prior disclosures. If anything, you can be guaranteed that you will NOT find all relevant disclosures.