An officer can stop and search you if they have a genuine suspicion in their mind that items that could be used to commit crime or are evidence of an offence (such as stolen property or weapons) will be found on you. Their suspicion must seem reasonable to an independent observer.
Being stopped and searched doesn't mean you're under arrest or have necessarily done anything wrong. It doesn't mean you will have a criminal record.
They must be able to explain what information or behaviour has caused them to be suspicious and stop and search you.