Abu Musa al-Ash’ari narrated that the Prophet Muhammad ﷺ said:
“People will go out from East and West in search of knowledge, and they shall find no one more knowledgeable than the knowledgeable scholar of Madinah.”
{Related by Imam al-Hakim}
Abu Hurayrah who narrated that the Prophet ﷺ said:
“Very soon will people beat the flanks of camels in search of knowledge, and they shall find no one more knowledgeable than the knowledgeable scholar of Madinah.”
{Sunan at-Tirmidhi}
Ibn Uyaynah, the teacher of Imam Shafi and contemporary of Malik said in the commentary of this hadith (tirmidhi cites it in the original arabic matn):
“We thought that this hadith refered to Malik”
he also said :
“It could refer to Umar Ibn Abdul ‘Aziz”
Malik fits the description better, however, and that was the interpretation the ummah took.