Java Code Examples for org.elasticsearch.index.mapper.MappedFieldType

The following examples show how to use org.elasticsearch.index.mapper.MappedFieldType. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Elasticsearch   Source File: MatchQueryBuilder.java    License: Apache License 2.0 6 votes vote down vote up
public Query createCommonTermsQuery(String field,
                                    String queryText,
                                    BooleanClause.Occur highFreqOccur,
                                    BooleanClause.Occur lowFreqOccur,
                                    Float maxTermFrequency,
                                    MappedFieldType mapper) {
    Query booleanQuery = createBooleanQuery(field, queryText, lowFreqOccur);
    if (booleanQuery != null && booleanQuery instanceof BooleanQuery) {
        BooleanQuery bq = (BooleanQuery) booleanQuery;
        ExtendedCommonTermsQuery query = new ExtendedCommonTermsQuery(
                highFreqOccur, lowFreqOccur, maxTermFrequency,
                ((BooleanQuery)booleanQuery).isCoordDisabled(), mapper);
        for (BooleanClause clause : bq.clauses()) {
            if (!(clause.getQuery() instanceof TermQuery)) {
                return booleanQuery;
            }
            query.add(((TermQuery) clause.getQuery()).getTerm());
        }
        return query;
    }
    return booleanQuery;
}
 
Example 2
Source Project: Elasticsearch   Source File: QueryCollector.java    License: Apache License 2.0 6 votes vote down vote up
QueryCollector(ESLogger logger, PercolateContext context, boolean isNestedDoc) throws IOException {
    this.logger = logger;
    this.queries = context.percolateQueries();
    this.searcher = context.docSearcher();
    final MappedFieldType uidMapper = context.mapperService().smartNameFieldType(UidFieldMapper.NAME);
    this.uidFieldData = context.fieldData().getForField(uidMapper);
    this.isNestedDoc = isNestedDoc;

    List<Aggregator> aggregatorCollectors = new ArrayList<>();

    if (context.aggregations() != null) {
        AggregationContext aggregationContext = new AggregationContext(context);
        context.aggregations().aggregationContext(aggregationContext);

        Aggregator[] aggregators = context.aggregations().factories().createTopLevelAggregators(aggregationContext);
        for (int i = 0; i < aggregators.length; i++) {
            if (!(aggregators[i] instanceof GlobalAggregator)) {
                Aggregator aggregator = aggregators[i];
                aggregatorCollectors.add(aggregator);
            }
        }
        context.aggregations().aggregators(aggregators);
    }
    aggregatorCollector = BucketCollector.wrap(aggregatorCollectors);
    aggregatorCollector.preCollection();
}
 
Example 3
@Override
public void hitExecute(SearchContext context, HitContext hitContext) {
    for (FieldDataFieldsContext.FieldDataField field : context.getFetchSubPhaseContext(CONTEXT_FACTORY).fields()) {
        if (hitContext.hit().fieldsOrNull() == null) {
            hitContext.hit().fields(new HashMap<String, SearchHitField>(2));
        }
        SearchHitField hitField = hitContext.hit().fields().get(field.name());
        if (hitField == null) {
            hitField = new InternalSearchHitField(field.name(), new ArrayList<>(2));
            hitContext.hit().fields().put(field.name(), hitField);
        }
        MappedFieldType fieldType = context.mapperService().smartNameFieldType(field.name());
        if (fieldType != null) {
            AtomicFieldData data = context.fieldData().getForField(fieldType).load(hitContext.readerContext());
            ScriptDocValues values = data.getScriptValues();
            values.setNextDocId(hitContext.docId());
            hitField.values().addAll(values.getValues());
        }
    }
}
 
Example 4
Source Project: Elasticsearch   Source File: LeafFieldsLookup.java    License: Apache License 2.0 6 votes vote down vote up
private FieldLookup loadFieldData(String name) {
    FieldLookup data = cachedFieldData.get(name);
    if (data == null) {
        MappedFieldType fieldType = mapperService.smartNameFieldType(name, types);
        if (fieldType == null) {
            throw new IllegalArgumentException("No field found for [" + name + "] in mapping with types " + Arrays.toString(types) + "");
        }
        data = new FieldLookup(fieldType);
        cachedFieldData.put(name, data);
    }
    if (data.fields() == null) {
        String fieldName = data.fieldType().names().indexName();
        fieldVisitor.reset(fieldName);
        try {
            reader.document(docId, fieldVisitor);
            fieldVisitor.postProcess(data.fieldType());
            data.fields(ImmutableMap.of(name, fieldVisitor.fields().get(data.fieldType().names().indexName())));
        } catch (IOException e) {
            throw new ElasticsearchParseException("failed to load field [{}]", e, name);
        }
    }
    return data;
}
 
Example 5
Source Project: Elasticsearch   Source File: FieldsVisitor.java    License: Apache License 2.0 6 votes vote down vote up
public void postProcess(MapperService mapperService) {
    if (uid != null) {
        DocumentMapper documentMapper = mapperService.documentMapper(uid.type());
        if (documentMapper != null) {
            // we can derive the exact type for the mapping
            postProcess(documentMapper);
            return;
        }
    }
    // can't derive exact mapping type
    for (Map.Entry<String, List<Object>> entry : fields().entrySet()) {
        MappedFieldType fieldType = mapperService.indexName(entry.getKey());
        if (fieldType == null) {
            continue;
        }
        List<Object> fieldValues = entry.getValue();
        for (int i = 0; i < fieldValues.size(); i++) {
            fieldValues.set(i, fieldType.valueForSearch(fieldValues.get(i)));
        }
    }
}
 
Example 6
Source Project: Elasticsearch   Source File: DecayFunctionParser.java    License: Apache License 2.0 6 votes vote down vote up
private AbstractDistanceScoreFunction parseVariable(String fieldName, XContentParser parser, QueryParseContext parseContext, MultiValueMode mode) throws IOException {

        // now, the field must exist, else we cannot read the value for
        // the doc later
        MappedFieldType fieldType = parseContext.fieldMapper(fieldName);
        if (fieldType == null) {
            throw new QueryParsingException(parseContext, "unknown field [{}]", fieldName);
        }

        // dates and time need special handling
        parser.nextToken();
        if (fieldType instanceof DateFieldMapper.DateFieldType) {
            return parseDateVariable(fieldName, parser, parseContext, (DateFieldMapper.DateFieldType) fieldType, mode);
        } else if (fieldType instanceof GeoPointFieldMapper.GeoPointFieldType) {
            return parseGeoVariable(fieldName, parser, parseContext, (GeoPointFieldMapper.GeoPointFieldType) fieldType, mode);
        } else if (fieldType instanceof NumberFieldMapper.NumberFieldType) {
            return parseNumberVariable(fieldName, parser, parseContext, (NumberFieldMapper.NumberFieldType) fieldType, mode);
        } else {
            throw new QueryParsingException(parseContext, "field [{}] is of type [{}], but only numeric types are supported.", fieldName, fieldType);
        }
    }
 
Example 7
Source Project: Elasticsearch   Source File: MultiMatchQuery.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Query blendTerm(Term term, MappedFieldType fieldType) {
    if (blendedFields == null) {
        return super.blendTerm(term, fieldType);
    }
    final Term[] terms = new Term[blendedFields.length];
    float[] blendedBoost = new float[blendedFields.length];
    for (int i = 0; i < blendedFields.length; i++) {
        terms[i] = blendedFields[i].newTerm(term.text());
        blendedBoost[i] = blendedFields[i].boost;
    }
    if (commonTermsCutoff != null) {
        return BlendedTermQuery.commonTermsBlendedQuery(terms, blendedBoost, false, commonTermsCutoff);
    }

    if (tieBreaker == 1.0f) {
        return BlendedTermQuery.booleanBlendedQuery(terms, blendedBoost, false);
    }
    return BlendedTermQuery.dismaxBlendedQuery(terms, blendedBoost, tieBreaker);
}
 
Example 8
Source Project: Elasticsearch   Source File: QueryParseContext.java    License: Apache License 2.0 6 votes vote down vote up
private MappedFieldType failIfFieldMappingNotFound(String name, MappedFieldType fieldMapping) {
    if (fieldMapping != null || allowUnmappedFields) {
        return fieldMapping;
    } else if (mapUnmappedFieldAsString){
        StringFieldMapper.Builder builder = MapperBuilders.stringField(name);
        // it would be better to pass the real index settings, but they are not easily accessible from here...
        Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, indexQueryParser.getIndexCreatedVersion()).build();
        return builder.build(new Mapper.BuilderContext(settings, new ContentPath(1))).fieldType();
    } else {
        Version indexCreatedVersion = indexQueryParser.getIndexCreatedVersion();
        if (fieldMapping == null && indexCreatedVersion.onOrAfter(Version.V_1_4_0_Beta1)) {
            throw new QueryParsingException(this, "Strict field resolution and no field mapping can be found for the field with name ["
                    + name + "]");
        } else {
            return fieldMapping;
        }
    }
}
 
Example 9
Source Project: crate   Source File: AnyNeqQuery.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected Query literalMatchesAnyArrayRef(Literal candidate, Reference array, LuceneQueryBuilder.Context context) throws IOException {
    // 1 != any ( col ) -->  gt 1 or lt 1
    String columnName = array.column().fqn();
    Object value = candidate.value();

    MappedFieldType fieldType = context.getFieldTypeOrNull(columnName);
    if (fieldType == null) {
        return Queries.newMatchNoDocsQuery("column does not exist in this index");
    }
    BooleanQuery.Builder query = new BooleanQuery.Builder();
    query.setMinimumNumberShouldMatch(1);
    query.add(
        fieldType.rangeQuery(value, null, false, false, null, null, context.queryShardContext),
        BooleanClause.Occur.SHOULD
    );
    query.add(
        fieldType.rangeQuery(null, value, false, false, null, null, context.queryShardContext),
        BooleanClause.Occur.SHOULD
    );
    return query.build();
}
 
Example 10
Source Project: Elasticsearch   Source File: ParentChildIndexFieldData.java    License: Apache License 2.0 6 votes vote down vote up
public ParentChildIndexFieldData(Index index, Settings indexSettings, MappedFieldType.Names fieldNames,
                                 FieldDataType fieldDataType, IndexFieldDataCache cache, MapperService mapperService,
                                 CircuitBreakerService breakerService) {
    super(index, indexSettings, fieldNames, fieldDataType, cache);
    this.breakerService = breakerService;
    if (Version.indexCreated(indexSettings).before(Version.V_2_0_0_beta1)) {
        parentTypes = new TreeSet<>();
        for (DocumentMapper documentMapper : mapperService.docMappers(false)) {
            beforeCreate(documentMapper);
        }
        mapperService.addTypeListener(this);
    } else {
        ImmutableSortedSet.Builder<String> builder = ImmutableSortedSet.naturalOrder();
        for (DocumentMapper mapper : mapperService.docMappers(false)) {
            ParentFieldMapper parentFieldMapper = mapper.parentFieldMapper();
            if (parentFieldMapper.active()) {
                builder.add(parentFieldMapper.type());
            }
        }
        parentTypes = builder.build();
    }
}
 
Example 11
Source Project: crate   Source File: AnyEqQuery.java    License: Apache License 2.0 6 votes vote down vote up
private static Query literalMatchesAnyArrayRef(Function any,
                                               Literal candidate,
                                               Reference array,
                                               LuceneQueryBuilder.Context context) {
    MappedFieldType fieldType = context.getFieldTypeOrNull(array.column().fqn());
    if (fieldType == null) {
        if (ArrayType.unnest(array.valueType()).id() == ObjectType.ID) {
            return genericFunctionFilter(any, context); // {x=10} = any(objects)
        }
        return Queries.newMatchNoDocsQuery("column doesn't exist in this index");
    }
    if (DataTypes.isArray(candidate.valueType())) {
        return arrayLiteralEqAnyArray(any, fieldType, candidate.value(), context);
    }
    return fieldType.termQuery(candidate.value(), context.queryShardContext());
}
 
Example 12
public ReferenceMapper(String simpleName,
                       MappedFieldType fieldType,
                       MappedFieldType defaultFieldType,
                       Client client,
                       String refindex,
                       String reftype,
                       List<String> reffields,
                       FieldMapper contentMapper,
                       Settings indexSettings,
                       MultiFields multiFields,
                       CopyTo copyTo) {
    super(simpleName, fieldType, defaultFieldType, indexSettings, multiFields, COPYTO_EMPTY);
    this.copyTo = copyTo;
    this.client = client;
    this.index = refindex;
    this.type = reftype;
    this.fields = reffields;
    this.contentMapper = contentMapper;
}
 
Example 13
Source Project: Elasticsearch   Source File: LuceneQueryBuilder.java    License: Apache License 2.0 5 votes vote down vote up
private static GeoPointFieldMapper.GeoPointFieldType getGeoPointFieldType(String fieldName, MapperService mapperService) {
    MappedFieldType fieldType =  mapperService.smartNameFieldType(fieldName);
    if (fieldType == null) {
        throw new IllegalArgumentException(String.format("column \"%s\" doesn't exist", fieldName));
    }
    if (!(fieldType instanceof GeoPointFieldMapper.GeoPointFieldType)) {
        throw new IllegalArgumentException(String.format("column \"%s\" isn't of type geo_point", fieldName));
    }
    return (GeoPointFieldMapper.GeoPointFieldType) fieldType;
}
 
Example 14
Source Project: Elasticsearch   Source File: SortSymbolVisitor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * generate a SortField from a Reference symbol.
 *
 * the implementation is similar to what {@link org.elasticsearch.search.sort.SortParseElement}
 * does.
 */
@Override
public SortField visitReference(final Reference symbol, final SortSymbolContext context) {
    // can't use the SortField(fieldName, type) constructor
    // because values are saved using docValues and therefore they're indexed in lucene as binary and not
    // with the reference valueType.
    // this is why we use a custom comparator source with the same logic as ES

    ColumnIdent columnIdent = symbol.info().ident().columnIdent();

    if (columnIdent.isColumn()) {
        if (SortParseElement.SCORE_FIELD_NAME.equals(columnIdent.name())) {
            return !context.reverseFlag ? SORT_SCORE_REVERSE : SortParseElement.SORT_SCORE;
        } else if (DocSysColumns.RAW.equals(columnIdent) || DocSysColumns.ID.equals(columnIdent)) {
            return customSortField(DocSysColumns.nameForLucene(columnIdent), symbol, context,
                    LUCENE_TYPE_MAP.get(symbol.valueType()), false);
        }
    }

    MultiValueMode sortMode = context.reverseFlag ? MultiValueMode.MAX : MultiValueMode.MIN;

    String indexName;
    IndexFieldData.XFieldComparatorSource fieldComparatorSource;
    MappedFieldType fieldType = context.context.mapperService().smartNameFieldType(columnIdent.fqn());
    if (fieldType == null){
        indexName = columnIdent.fqn();
        fieldComparatorSource = new NullFieldComparatorSource(LUCENE_TYPE_MAP.get(symbol.valueType()), context.reverseFlag, context.nullFirst);
    } else {
        indexName = fieldType.names().indexName();
        fieldComparatorSource = context.context.fieldData()
                .getForField(fieldType)
                .comparatorSource(SortOrder.missing(context.reverseFlag, context.nullFirst), sortMode, null);
    }
    return new SortField(
            indexName,
            fieldComparatorSource,
            context.reverseFlag
    );
}
 
Example 15
Source Project: Elasticsearch   Source File: GeoPointFieldMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public GeoPointFieldMapper build(BuilderContext context, String simpleName, MappedFieldType fieldType,
                                 MappedFieldType defaultFieldType, Settings indexSettings, ContentPath.Type pathType, DoubleFieldMapper latMapper,
                                 DoubleFieldMapper lonMapper, StringFieldMapper geoHashMapper, MultiFields multiFields, Explicit<Boolean> ignoreMalformed,
                                 CopyTo copyTo) {
    fieldType.setTokenized(false);
    if (context.indexCreatedVersion().before(Version.V_2_3_0)) {
        fieldType.setNumericPrecisionStep(GeoPointField.PRECISION_STEP);
        fieldType.setNumericType(FieldType.NumericType.LONG);
    }
    setupFieldType(context);
    return new GeoPointFieldMapper(simpleName, fieldType, defaultFieldType, indexSettings, pathType, latMapper, lonMapper,
            geoHashMapper, multiFields, ignoreMalformed, copyTo);
}
 
Example 16
Source Project: crate   Source File: MatchQuery.java    License: Apache License 2.0 5 votes vote down vote up
protected final Query termQuery(MappedFieldType fieldType, BytesRef value, boolean lenient) {
    try {
        return fieldType.termQuery(value, context);
    } catch (RuntimeException e) {
        if (lenient) {
            return newLenientFieldQuery(fieldType.name(), e);
        }
        throw e;
    }
}
 
Example 17
public StandardnumberMapper(Settings settings,
                            String simpleName,
                            MappedFieldType fieldType,
                            MappedFieldType defaultFieldType,
                            Settings indexSettings,
                            MultiFields multiFields,
                            CopyTo copyTo,
                            StandardnumberService service) {
    super(simpleName, fieldType, defaultFieldType, indexSettings, multiFields, copyTo);
    this.settings = settings;
    this.service = service;
}
 
Example 18
@Override
public void checkCompatibility(MappedFieldType otherFT, List<String> conflicts, boolean strict) {
    super.checkCompatibility(otherFT, conflicts, strict);
    CollationFieldType other = (CollationFieldType) otherFT;
    if (!Objects.equals(collator, other.collator)) {
        conflicts.add("mapper [" + name() + "] has different [collator]");
    }
}
 
Example 19
Source Project: crate   Source File: MultiMatchQuery.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Query blendTermsQuery(Term[] terms, MappedFieldType fieldType) {
    if (queryBuilder == null) {
        return super.blendTermsQuery(terms, fieldType);
    }
    return queryBuilder.blendTerms(terms, fieldType);
}
 
Example 20
Source Project: Elasticsearch   Source File: MultiMatchQuery.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Query termQuery(MappedFieldType fieldType, Object value) {
    /*
     * Use the string value of the term because we're reusing the
     * portion of the query is usually after the analyzer has run on
     * each term. We just skip that analyzer phase.
     */
    return blendTerm(new Term(fieldType.names().indexName(), value.toString()), fieldType);
}
 
Example 21
Source Project: Elasticsearch   Source File: BaseGeoPointFieldMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean checkCompatibility(MappedFieldType fieldType, List<String> conflicts, boolean strict, boolean reindex) {
    boolean needReindex = super.checkCompatibility(fieldType, conflicts, strict, reindex);
    GeoPointFieldType other = (GeoPointFieldType)fieldType;
    if (isLatLonEnabled() != other.isLatLonEnabled()) {
        conflicts.add("mapper [" + names().fullName() + "] has different [lat_lon]");
        needReindex = true;
    }
    if (isLatLonEnabled() && other.isLatLonEnabled() &&
            latFieldType().numericPrecisionStep() != other.latFieldType().numericPrecisionStep()) {
        conflicts.add("mapper [" + names().fullName() + "] has different [precision_step]");
        needReindex = true;
    }
    if (isGeoHashEnabled() != other.isGeoHashEnabled()) {
        conflicts.add("mapper [" + names().fullName() + "] has different [geohash]");
        needReindex = true;
    }
    if (geoHashPrecision() != other.geoHashPrecision()) {
        conflicts.add("mapper [" + names().fullName() + "] has different [geohash_precision]");
        needReindex = true;
    }
    if (isGeoHashPrefixEnabled() != other.isGeoHashPrefixEnabled()) {
        conflicts.add("mapper [" + names().fullName() + "] has different [geohash_prefix]");
        needReindex = true;
    }

    // if reindex is true, ignore above conflicts
    if (reindex) {
        conflicts.clear();
    }

    return needReindex;
}
 
Example 22
Source Project: Elasticsearch   Source File: QueryParseContext.java    License: Apache License 2.0 5 votes vote down vote up
/** Gets the search quote nalyzer for the given field, or the default if there is none present for the field
 * TODO: remove this by moving defaults into mappers themselves
 */
public Analyzer getSearchQuoteAnalyzer(MappedFieldType fieldType) {
    if (fieldType.searchQuoteAnalyzer() != null) {
        return fieldType.searchQuoteAnalyzer();
    }
    return mapperService().searchQuoteAnalyzer();
}
 
Example 23
Source Project: crate   Source File: MultiMatchQuery.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Query blendPhrase(PhraseQuery query, MappedFieldType type) {
    if (blendedFields == null) {
        return super.blendPhrase(query, type);
    }
    /**
     * We build phrase queries for multi-word synonyms when {@link QueryBuilder#autoGenerateSynonymsPhraseQuery} is true.
     */
    return MultiMatchQuery.blendPhrase(query, tieBreaker, blendedFields);
}
 
Example 24
InternalGlobalOrdinalsIndexFieldData(Index index, Settings settings, MappedFieldType.Names fieldNames, FieldDataType fieldDataType, AtomicOrdinalsFieldData[] segmentAfd, OrdinalMap ordinalMap, long memorySizeInBytes) {
    super(index, settings, fieldNames, fieldDataType, memorySizeInBytes);
    this.atomicReaders = new Atomic[segmentAfd.length];
    for (int i = 0; i < segmentAfd.length; i++) {
        atomicReaders[i] = new Atomic(segmentAfd[i], ordinalMap, i);
    }
}
 
Example 25
Source Project: crate   Source File: PerFieldMappingPostingFormatCodec.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public PostingsFormat getPostingsFormatForField(String field) {
    final MappedFieldType fieldType = mapperService.fullName(field);
    if (fieldType == null) {
        logger.warn("no index mapper found for field: [{}] returning default postings format", field);
    }
    return super.getPostingsFormatForField(field);
}
 
Example 26
@Override
public IndexFieldData<?> build(Index index, Settings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
                               CircuitBreakerService breakerService, MapperService mapperService) {
    // Ignore breaker
    return new GeoPointDVIndexFieldData(index, fieldType.names(), fieldType.fieldDataType(),
            Version.indexCreated(indexSettings).before(Version.V_2_2_0));
}
 
Example 27
Source Project: Elasticsearch   Source File: ParentChildIndexFieldData.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public IndexFieldData<?> build(Index index, Settings indexSettings, MappedFieldType fieldType,
                               IndexFieldDataCache cache, CircuitBreakerService breakerService,
                               MapperService mapperService) {
    return new ParentChildIndexFieldData(index, indexSettings, fieldType.names(), fieldType.fieldDataType(), cache,
        mapperService, breakerService);
}
 
Example 28
Source Project: crate   Source File: MultiMatchQuery.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Query termQuery(MappedFieldType fieldType, BytesRef value) {
    /*
     * Use the string value of the term because we're reusing the
     * portion of the query is usually after the analyzer has run on
     * each term. We just skip that analyzer phase.
     */
    return blendTerm(new Term(fieldType.name(), value.utf8ToString()), fieldType);
}
 
Example 29
Source Project: Elasticsearch   Source File: BytesBinaryDVIndexFieldData.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public IndexFieldData<?> build(Index index, Settings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache,
                               CircuitBreakerService breakerService, MapperService mapperService) {
    // Ignore breaker
    final Names fieldNames = fieldType.names();
    return new BytesBinaryDVIndexFieldData(index, fieldNames, fieldType.fieldDataType());
}
 
Example 30
Source Project: crate   Source File: MultiMatchQuery.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Query blendTerms(Term[] terms, MappedFieldType fieldType) {
    if (blendedFields == null || blendedFields.length == 1) {
        return super.blendTerms(terms, fieldType);
    }
    BytesRef[] values = new BytesRef[terms.length];
    for (int i = 0; i < terms.length; i++) {
        values[i] = terms[i].bytes();
    }
    return MultiMatchQuery.blendTerms(context, values, commonTermsCutoff, tieBreaker, blendedFields);
}