Find similarity between two fields of an index

My index:
{"var1": "abc", "var2": "ert","var3": "ca","var4": "sdf"}
{"var1": "ert", "var2": "abc","var3": "La","var4": "abc"}
{"var1": "vbn", "var2": "fgh","var3": "ert","var4": "vbh"}
{"var1": "fgh", "var2": "tyu","var3": "sdg","var4": "sdf"}

I want to write a query to find the similarity between fields of my index.

in this case, the intersection should be var1 & var2 -> 3 , var1&var3 ->1, var1&var4 -> 2, var2&var3->1, var2&var4->1, var3&var4->0

anything close to this is possible?