All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.elasticsearch.xpack.esql.enrich.ResolvedEnrichPolicy Maven / Gradle / Ivy

There is a newer version: 8.16.1
Show newest version
/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License
 * 2.0; you may not use this file except in compliance with the Elastic License
 * 2.0.
 */

package org.elasticsearch.xpack.esql.enrich;

import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.xpack.esql.core.type.EsField;

import java.io.IOException;
import java.util.List;
import java.util.Map;

public record ResolvedEnrichPolicy(
    String matchField,
    String matchType,
    List enrichFields,
    Map concreteIndices,
    Map mapping
) implements Writeable {
    public ResolvedEnrichPolicy(StreamInput in) throws IOException {
        this(
            in.readString(),
            in.readString(),
            in.readStringCollectionAsList(),
            in.readMap(StreamInput::readString),
            in.readMap(EsField::new)
        );
    }

    @Override
    public void writeTo(StreamOutput out) throws IOException {
        out.writeString(matchField);
        out.writeString(matchType);
        out.writeStringCollection(enrichFields);
        out.writeMap(concreteIndices, StreamOutput::writeString);
        out.writeMap(
            mapping,
            /*
             * There are lots of subtypes of ESField, but we always write the field
             * as though it were the base class.
             */
            (o, v) -> new EsField(v.getName(), v.getDataType(), v.getProperties(), v.isAggregatable(), v.isAlias()).writeTo(o)
        );
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy