本文整理匯總了Java中org.elasticsearch.index.query.QueryBuilders.fuzzyQuery方法的典型用法代碼示例。如果您正苦於以下問題:Java QueryBuilders.fuzzyQuery方法的具體用法?Java QueryBuilders.fuzzyQuery怎麽用?Java QueryBuilders.fuzzyQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.elasticsearch.index.query.QueryBuilders
的用法示例。
在下文中一共展示了QueryBuilders.fuzzyQuery方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: randomFuzzyQuery
import org.elasticsearch.index.query.QueryBuilders; //導入方法依賴的package包/類
private static QueryBuilder randomFuzzyQuery(List<String> fields) {
QueryBuilder q = QueryBuilders.fuzzyQuery(randomField(fields), randomQueryString(1));
if (randomBoolean()) {
((FuzzyQueryBuilder)q).boost(randomFloat());
}
if (randomBoolean()) {
switch (randomIntBetween(0, 4)) {
case 0:
((FuzzyQueryBuilder)q).fuzziness(Fuzziness.AUTO);
break;
case 1:
((FuzzyQueryBuilder)q).fuzziness(Fuzziness.ONE);
break;
case 2:
((FuzzyQueryBuilder)q).fuzziness(Fuzziness.TWO);
break;
case 3:
((FuzzyQueryBuilder)q).fuzziness(Fuzziness.ZERO);
break;
case 4:
((FuzzyQueryBuilder)q).fuzziness(Fuzziness.fromEdits(randomIntBetween(0,2)));
break;
default:
((FuzzyQueryBuilder)q).fuzziness(Fuzziness.AUTO);
break;
}
}
if (randomBoolean()) {
((FuzzyQueryBuilder)q).maxExpansions(Math.abs(randomInt()));
}
if (randomBoolean()) {
((FuzzyQueryBuilder)q).prefixLength(Math.abs(randomInt()));
}
if (randomBoolean()) {
((FuzzyQueryBuilder)q).transpositions(randomBoolean());
}
return q;
}