public static WeightedTerm[] getTerms(Query query, boolean prohibited, String fieldName) {HashSet<WeightedTerm> terms = new HashSet<>();Predicate<String> fieldSelector = fieldName == null ? f -> true : fieldName::equals;query.visit(new BoostedTermExtractor(1, terms, prohibited, fieldSelector));return terms.toArray(new WeightedTerm[0]);}