Created
February 15, 2024 02:16
-
-
Save hfleitas/c308f7d40e63c7c6c1c5d6f128e75d9e to your computer and use it in GitHub Desktop.
VectorSearch.kql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let series_cosine_similarity_fl=(vec1:dynamic, vec2:dynamic, vec1_size:real=double(null), vec2_size:real=double(null)) | |
{ | |
let dp = series_dot_product(vec1, vec2); | |
let v1l = iff(isnull(vec1_size), sqrt(series_dot_product(vec1, vec1)), vec1_size); | |
let v2l = iff(isnull(vec2_size), sqrt(series_dot_product(vec2, vec2)), vec2_size); | |
dp/(v1l*v2l) | |
}; | |
let s1=pack_array(0, 1); | |
let s2=pack_array(sqrt(2), sqrt(2)); | |
print angle=acos(series_cosine_similarity_fl(s1, s2))/(2*pi())*360 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment