From the Wikipedia article on Rhyming Slang:
One example is replacing the word "stairs" with the rhyming phrase "apples and pears". Following the pattern of omission, "and pears" is dropped, thus the spoken phrase "I'm going up the apples" means "I'm going up the stairs".
But when the first person says "apples and pears", how do people know what "pears" is supposed to rhyme with? Does someone say it with clear context like "let me just run up the apples and pears here", and use it like that until everyone knows the expression? And then do people start dropping the "and pears" until that becomes well known? Is there any study of how this works in practice?