private void findCosineSimilarity(String [] words, Vector<Double> queryVector) {
        Double queryVectorLength = 0d;
            for(Double elem: queryVector) {
                queryVectorLength += Math.pow(elem, 2);
            }
            queryVectorLength = Math.sqrt(queryVectorLength);
        //dot products
        for (Integer docId: leaders) {
            double dotProduct = 0;
            for(String word: words) {
                if(tf_Idf.containsKey(word)) {
                    HashMap<Integer, Double> map = tf_Idf.get(word);
                    if(map.containsKey(docId)) {
                        double doc_word_tfIdf = (double)map.get(docId);
                        double query_word_idf = Math.log((double)FREE_DOC_ID/
                                (double)index.get(word).size());
                        dotProduct += doc_word_tfIdf * query_word_idf;
                    }
                }              
            }
            double cosineSimilarity = dotProduct/
                     (queryVectorLength*vecLenght.get(docId));
            cosineSimilarities.put(docId, cosineSimilarity);
        }
        cosineSimilarities = (HashMap<Integer, Double>)sortByComparator(cosineSimilarities);
    }