You were asked for your ID as part of that investigation and if you didn't willingly produce it, yes, the police have the right to search you for it.
Now, if they found something on you that didn't pertain to the search, that would constitute illegal search.
I get what you're saying. Police just can't randomly stop a citizen and "demand" ID. In this case, the disturbance created the investigation.
I'm interested to see where this goes but I've explained my educated response to the questions.