It sounds like you want to know where the results for Spotlight Searches come from or how they are populated when you use this feature on your iPhone. The magnifying glass you are referring to is called Spotlight Suggestions, and I can give you an overview that can help explain how this works. If you have Suggestions in Search enabled when you go to Settings > Siri & Search, this allows Siri to learn how you use your devices in order to personalize your experience.You can learn more about this at the following link below.
Although this says it is for macOS High Sierra, please note that Siri for macOS is built with the same privacy features as Siri for iOS.
Search with Spotlight
You may find what you're looking for when you click "Spotlight Suggestions"
Hope this answers your question.Spotlight Suggestions
Siri analyzes how you use your device to provide personalized suggestions and better search
Siri learns how you use your devices in order to personalize your experience. Using information stored on your device, such as your Safari browsing history, emails, messages, and contacts, as well as information contributed by other installed apps, Siri can provide suggestions in Spotlight, Look Up, Photos Memories, and more.
Cheers