use of org.elasticsearch.index.query.CommonTermsQueryBuilder in project elasticsearch by elastic.
the class RandomQueryGenerator method randomCommonTermsQuery.
private static QueryBuilder randomCommonTermsQuery(List<String> fields, int numDocs) {
int numTerms = randomInt(numDocs);
QueryBuilder q = QueryBuilders.commonTermsQuery(randomField(fields), randomQueryString(numTerms));
if (randomBoolean()) {
((CommonTermsQueryBuilder) q).boost(randomFloat());
}
if (randomBoolean()) {
((CommonTermsQueryBuilder) q).cutoffFrequency(randomFloat());
}
if (randomBoolean()) {
((CommonTermsQueryBuilder) q).highFreqMinimumShouldMatch(Integer.toString(randomInt(numTerms))).highFreqOperator(randomBoolean() ? Operator.AND : Operator.OR);
}
if (randomBoolean()) {
((CommonTermsQueryBuilder) q).lowFreqMinimumShouldMatch(Integer.toString(randomInt(numTerms))).lowFreqOperator(randomBoolean() ? Operator.AND : Operator.OR);
}
return q;
}
Aggregations