When light of a certain frequency hits a molecule that has a vibration whose motion corresponds to the same frequency then the light gets absorbed into the molecule and the energy from the light causes the bonds to move in that specific vibrational motion. By checking for light that gets absorbed, scientists can tell if a certain kind of molecular bond is there and match it against a list of molecules that have that bond.