private void addTerm(String term, int docId) {
        if(!index.containsKey(term)) {
           Integer freq = 1;
           HashMap<Integer, Integer> pair = new HashMap<>();
           pair.put(docId, freq);
           index.put(term, pair);
        } else if (index.containsKey(term) && index.get(term).containsKey(docId)) {
            int counter =  index.get(term).get(docId);
            index.get(term).put(docId,++counter);
        } else {
            index.get(term).put(docId, 1);
        }
        
    }