/** * Terms counter. * * @param termSpec the term spec * @return the counter */ default Counter<String> terms(@NonNull TermSpec termSpec) { return termSpec .getValueCalculator() .adjust( new HashMapCounter<>( stream() .flatMap( doc -> doc.get(termSpec.getAnnotationType()) .stream() .filter(termSpec.getFilter()) .map(termSpec.getToStringFunction()) .collect(Collectors.toList())) .countByValue())); }
/** * Terms counter. * * @return the counter */ default Counter<String> terms() { return terms(TermSpec.create()); }