private void finalCosSim(ArrayList<Integer> lst) {
         Double queryVectorLength = 0d;
            for(Double elem: queryVector) {
                queryVectorLength += Math.pow(elem, 2);
            }
            queryVectorLength = Math.sqrt(queryVectorLength);
            cosineSimilarities = new HashMap<>();
        //dot products
        for (Integer docId: lst) {
            double dotProduct = 0;
            for(String word: queryWords) {
                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);
    }