MultiMatchQueryTranslatorImpl extends BaseMatchQueryTranslatorImpl implements MultiMatchQueryTranslator { @Override public QueryBuilder translate(MultiMatchQuery multiMatchQuery) { MultiMatchQueryBuilder multiMatchQueryBuilder = QueryBuilders.multiMatchQuery(multiMatchQuery.getValue()); if (Validator.isNotNull(multiMatchQuery.getAnalyzer())) { multiMatchQueryBuilder.analyzer(multiMatchQuery.getAnalyzer()); } if (multiMatchQuery.getCutOffFrequency() != null) { multiMatchQueryBuilder.cutoffFrequency( multiMatchQuery.getCutOffFrequency()); } Map<String, Float> fieldsBoosts = multiMatchQuery.getFieldsBoosts(); for (Map.Entry<String, Float> entry : fieldsBoosts.entrySet()) { Float boost = entry.getValue(); String field = entry.getKey(); if (boost == null) { multiMatchQueryBuilder.field(field); } else { multiMatchQueryBuilder.field(field, boost); } } if (multiMatchQuery.getFuzziness() != null) { multiMatchQueryBuilder.fuzziness( Fuzziness.build(multiMatchQuery.getFuzziness())); } if (multiMatchQuery.getFuzzyRewriteMethod() != null) { String multiMatchQueryFuzzyRewriteMethod = translate( multiMatchQuery.getFuzzyRewriteMethod()); multiMatchQueryBuilder.fuzzyRewrite( multiMatchQueryFuzzyRewriteMethod); } if (multiMatchQuery.getMaxExpansions() != null) { multiMatchQueryBuilder.maxExpansions( multiMatchQuery.getMaxExpansions()); } if (Validator.isNotNull(multiMatchQuery.getMinShouldMatch())) { multiMatchQueryBuilder.minimumShouldMatch( multiMatchQuery.getMinShouldMatch()); } if (multiMatchQuery.getOperator() != null) { Operator matchQueryBuilderOperator = translate( multiMatchQuery.getOperator()); multiMatchQueryBuilder.operator(matchQueryBuilderOperator); } if (multiMatchQuery.getPrefixLength() != null) { multiMatchQueryBuilder.prefixLength( multiMatchQuery.getPrefixLength()); } if (multiMatchQuery.getSlop() != null) { multiMatchQueryBuilder.slop(multiMatchQuery.getSlop()); } if (multiMatchQuery.getType() != null) { MultiMatchQueryBuilder.Type multiMatchQueryBuilderType = translate( multiMatchQuery.getType()); multiMatchQueryBuilder.type(multiMatchQueryBuilderType); } if (multiMatchQuery.getZeroTermsQuery() != null) { MatchQuery.ZeroTermsQuery multiMatchQueryBuilderZeroTermsQuery = translate(multiMatchQuery.getZeroTermsQuery()); multiMatchQueryBuilder.zeroTermsQuery( multiMatchQueryBuilderZeroTermsQuery); } if (multiMatchQuery.isLenient() != null) { multiMatchQueryBuilder.lenient(multiMatchQuery.isLenient()); } return multiMatchQueryBuilder; }  @Override QueryBuilder translate(MultiMatchQuery multiMatchQuery);  }
@Test public void testTranslate() { MultiMatchQueryTranslatorImpl multiMatchQueryTranslatorImpl = new MultiMatchQueryTranslatorImpl(); Map<String, Float> fieldsBoosts = new HashMap<>(); fieldsBoosts.put("test", null); MultiMatchQuery multiMatchQuery = new MultiMatchQueryImpl( "test", fieldsBoosts); multiMatchQueryTranslatorImpl.translate(multiMatchQuery); }