public void boolSearchByFraze(String query) throws Exception {
        boolean skip = false;
        ArrayList<BitSet> terms = new ArrayList<>();
        LinkedList<String> operators = new LinkedList<>();
        String[] line = query.split(" ");
        for(int i = 0; i<line.length; i++) {
            if(line[i].matches("NOT")) {
                if(matrix.containsKey(line[i+1])) {
                    terms.add(invert(matrix.get(line[i+1])));
                    i++;
                } else {
                    skip = true;
                }
            }
            else if(line[i].matches("AND") || line[i].matches("OR")) {
                if(!skip) {
                    operators.add(line[i]);
                    skip = false;
                }
            } else {
                if(matrix.containsKey(line[i]))
                    terms.add(matrix.get(line[i]));
                else {
                    skip = true;
                }
            }
        }
        
        if (terms.isEmpty()) {
            System.out.println("Try another query");
            System.exit(0);
        }
        
        if(terms.size() == 1) {
             BitSet result = terms.get(0);
             System.out.println("Query: " + query);
             System.out.println("Result: ");
             for(int i = 0; i<docNumber; i++) {
                if (result.get(i) == true)
                    System.out.println(getDocName(i));
            }
        } else {
            BitSet result = terms.get(0);
            int j = 1;
            for (String elem : operators) {
                if (elem.matches("AND")) {
                    result.and(terms.get(j));
                    j++;
                }
                else if(elem.matches("OR")) {
                    result.or(terms.get(j));
                    j++;
                }
            }
            System.out.println("Query: " + query);
            System.out.println("Result: ");
            for(int i = 0; i<docNumber; i++) {
                if (result.get(i) == true)
                    System.out.println(getDocName(i));
            }
        }
    }