Access similarity in java native script

hi all
i am using elasticsearch engine and i don't want to use it's scoring algorithm so i write a plugin and use java native script in order to score and sort document with my own algorithm. i use multi_match query and now i need similarity and edit distance between terms that match to my query and my query. how can i access edit distance and similarity between terms of document and my query ?