org.elasticsearch.script.FieldScript Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of elasticsearch Show documentation
Show all versions of elasticsearch Show documentation
Elasticsearch subproject :server
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
package org.elasticsearch.script;
import org.apache.lucene.index.LeafReaderContext;
import org.elasticsearch.common.logging.DeprecationCategory;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.search.lookup.SearchLookup;
import org.elasticsearch.search.lookup.Source;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.function.Supplier;
/**
* A script to produce dynamic values for return fields.
*/
public abstract class FieldScript extends DocBasedScript {
public static final String[] PARAMETERS = {};
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class);
@SuppressWarnings("unchecked")
private static final Map> PARAMS_FUNCTIONS = Map.of("doc", value -> {
deprecationLogger.warn(
DeprecationCategory.SCRIPTING,
"field-script_doc",
"Accessing variable [doc] via [params.doc] from within an field-script " + "is deprecated in favor of directly accessing [doc]."
);
return value;
}, "_doc", value -> {
deprecationLogger.warn(
DeprecationCategory.SCRIPTING,
"field-script__doc",
"Accessing variable [doc] via [params._doc] from within an field-script "
+ "is deprecated in favor of directly accessing [doc]."
);
return value;
}, "_source", value -> ((Supplier