Similar sentiments and beliefs are not the essence of what I meant. The way one structure one's thoughts, mindstates or the atmosphere of the mind is. I tried illustrating what I mean:
Let's say two people think about how lonely they are. In the upper image, you have two people thinking about loneliness. As you can see, their thought processes and emotions are different, but they are both thinking about the same thing.
In the lower image, you have two who might be very different, but then they at the same time think and feel about loneliness the same way. This could be a snapshot, a moment of 2 seconds of thinking. If the look at each other, they might be able to recognize it in each other.
(This is simplified to illustrate).
To experience the zap you probably need another ingredient, though. Vulnerability is a factor that trigger a feeling that can be quite intense if it feels intimate. If one rarely find someone to share this experience with, that can make the moment more precious. So can attraction. Or already considering someone a friend and then experience a moment like this to treasure. How you think probably also influences it. Not everyone would have an intense experience even if they did recognize something like this.