What ad service? App Store ads? Those are based only on the actual search term.
But summary is they use a bunch of stuff about the device (past purchases, location, fingerprinting-like data such as carrier and so on) and your usage of a bunch of apps like apple news and stocks.